fix(android): reset isLoading after signing completes to enable broadcast button
The broadcast button was disabled because isLoading remained true after signing completed. Added isLoading = false reset in startSigningProcess after waitForSignature succeeds or fails. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
001f0ac480
commit
f8de55e671
|
|
@ -1244,10 +1244,12 @@ class MainViewModel @Inject constructor(
|
||||||
onSuccess = { result ->
|
onSuccess = { result ->
|
||||||
android.util.Log.d("MainViewModel", "[SIGN] Signature received: ${result.signature.take(20)}...")
|
android.util.Log.d("MainViewModel", "[SIGN] Signature received: ${result.signature.take(20)}...")
|
||||||
_signature.value = result.signature
|
_signature.value = result.signature
|
||||||
|
// IMPORTANT: Reset isLoading so broadcast button is enabled
|
||||||
|
_uiState.update { it.copy(isLoading = false) }
|
||||||
},
|
},
|
||||||
onFailure = { e ->
|
onFailure = { e ->
|
||||||
android.util.Log.e("MainViewModel", "[SIGN] waitForSignature FAILED: ${e.message}")
|
android.util.Log.e("MainViewModel", "[SIGN] waitForSignature FAILED: ${e.message}")
|
||||||
_uiState.update { it.copy(error = e.message) }
|
_uiState.update { it.copy(isLoading = false, error = e.message) }
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -1257,26 +1259,37 @@ class MainViewModel @Inject constructor(
|
||||||
* Broadcast the signed transaction
|
* Broadcast the signed transaction
|
||||||
*/
|
*/
|
||||||
fun broadcastTransaction() {
|
fun broadcastTransaction() {
|
||||||
|
android.util.Log.d("MainViewModel", "[BROADCAST] broadcastTransaction() called")
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
|
android.util.Log.d("MainViewModel", "[BROADCAST] Starting broadcast...")
|
||||||
_uiState.update { it.copy(isLoading = true, error = null) }
|
_uiState.update { it.copy(isLoading = true, error = null) }
|
||||||
|
|
||||||
val tx = _preparedTx.value
|
val tx = _preparedTx.value
|
||||||
val sig = _signature.value
|
val sig = _signature.value
|
||||||
|
|
||||||
|
android.util.Log.d("MainViewModel", "[BROADCAST] preparedTx: ${tx?.let { "present" } ?: "null"}")
|
||||||
|
android.util.Log.d("MainViewModel", "[BROADCAST] signature: ${sig?.let { "${it.take(20)}..." } ?: "null"}")
|
||||||
|
|
||||||
if (tx == null || sig == null) {
|
if (tx == null || sig == null) {
|
||||||
|
android.util.Log.e("MainViewModel", "[BROADCAST] Missing tx or signature! tx=$tx, sig=$sig")
|
||||||
_uiState.update { it.copy(isLoading = false, error = "交易或签名缺失") }
|
_uiState.update { it.copy(isLoading = false, error = "交易或签名缺失") }
|
||||||
return@launch
|
return@launch
|
||||||
}
|
}
|
||||||
|
|
||||||
val rpcUrl = _settings.value.kavaRpcUrl
|
val rpcUrl = _settings.value.kavaRpcUrl
|
||||||
|
android.util.Log.d("MainViewModel", "[BROADCAST] Using RPC URL: $rpcUrl")
|
||||||
val result = repository.broadcastTransaction(tx, sig, rpcUrl)
|
val result = repository.broadcastTransaction(tx, sig, rpcUrl)
|
||||||
|
|
||||||
|
android.util.Log.d("MainViewModel", "[BROADCAST] repository.broadcastTransaction returned: isSuccess=${result.isSuccess}")
|
||||||
|
|
||||||
result.fold(
|
result.fold(
|
||||||
onSuccess = { hash ->
|
onSuccess = { hash ->
|
||||||
|
android.util.Log.d("MainViewModel", "[BROADCAST] SUCCESS! txHash=$hash")
|
||||||
_txHash.value = hash
|
_txHash.value = hash
|
||||||
_uiState.update { it.copy(isLoading = false, successMessage = "交易已广播!") }
|
_uiState.update { it.copy(isLoading = false, successMessage = "交易已广播!") }
|
||||||
},
|
},
|
||||||
onFailure = { e ->
|
onFailure = { e ->
|
||||||
|
android.util.Log.e("MainViewModel", "[BROADCAST] FAILED: ${e.message}", e)
|
||||||
_uiState.update { it.copy(isLoading = false, error = e.message) }
|
_uiState.update { it.copy(isLoading = false, error = e.message) }
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue