fix(wallet): surface background sync failures

This commit is contained in:
Ricardo Guilherme Schmidt 2026-07-17 20:11:52 -03:00
parent f8c0fa63c0
commit 9c4ade7237
No known key found for this signature in database
GPG Key ID: 1396EA17DE132FFE
2 changed files with 44 additions and 1 deletions

View File

@ -14,6 +14,7 @@ Item {
property real viewportWidth: width
property int selectedIndex: 0
property bool busy: false
property string handledSyncError: ""
readonly property bool connected: root.wallet !== null && root.wallet.isWalletOpen
readonly property string syncStatus: root.wallet
@ -74,6 +75,19 @@ Item {
messageDialog.open()
}
function handleSyncFailure() {
if (!root.wallet || root.syncStatus !== "error") {
root.handledSyncError = ""
return
}
const error = String(root.wallet.walletSyncError || "")
if (error.length === 0 || error === root.handledSyncError)
return
root.handledSyncError = error
root.busy = false
root.showError(qsTr("Wallet synchronization failed: %1").arg(error))
}
function openWallet() {
if (!root.wallet || root.busy)
return
@ -116,6 +130,14 @@ Item {
function onRowsRemoved() { root.clampSelection() }
}
Connections {
target: root.wallet
ignoreUnknownSignals: true
function onWalletSyncStatusChanged() { root.handleSyncFailure() }
function onWalletSyncErrorChanged() { root.handleSyncFailure() }
}
onConnectedChanged: {
if (!root.connected) {
root.selectedIndex = 0

View File

@ -14,6 +14,9 @@ Item {
property bool isWalletOpen: false
property bool walletExists: true
property string walletHome: "/wallet"
property string walletSyncStatus: "closed"
property string walletSyncError: ""
property bool deferOpen: false
property int openCalls: 0
property int createCalls: 0
property int publicAccountCalls: 0
@ -22,7 +25,12 @@ Item {
function openExisting() {
openCalls++
isWalletOpen = true
if (deferOpen) {
walletSyncStatus = "opening"
} else {
isWalletOpen = true
walletSyncStatus = "ready"
}
return true
}
@ -133,6 +141,19 @@ Item {
tryCompare(fixture.control, "connected", true)
}
function test_surfacesDeferredOpenFailure() {
const fixture = createControl({ walletExists: true, deferOpen: true }, [])
mouseClick(findChild(fixture.control, "walletConnectButton"))
compare(fixture.backend.openCalls, 1)
compare(fixture.control.syncStatus, "opening")
fixture.backend.walletSyncStatus = "error"
fixture.backend.walletSyncError = "open_failed"
const dialog = findChild(fixture.control, "walletMessageDialog")
tryCompare(dialog, "opened", true)
verify(dialog.message.includes("open_failed"))
}
function test_requiresSeedBackupAcknowledgement() {
const fixture = createControl({ walletExists: false }, [])
mouseClick(findChild(fixture.control, "walletConnectButton"))