mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-07-23 15:23:16 +00:00
fix(wallet): surface background sync failures
This commit is contained in:
parent
f8c0fa63c0
commit
9c4ade7237
@ -14,6 +14,7 @@ Item {
|
|||||||
property real viewportWidth: width
|
property real viewportWidth: width
|
||||||
property int selectedIndex: 0
|
property int selectedIndex: 0
|
||||||
property bool busy: false
|
property bool busy: false
|
||||||
|
property string handledSyncError: ""
|
||||||
|
|
||||||
readonly property bool connected: root.wallet !== null && root.wallet.isWalletOpen
|
readonly property bool connected: root.wallet !== null && root.wallet.isWalletOpen
|
||||||
readonly property string syncStatus: root.wallet
|
readonly property string syncStatus: root.wallet
|
||||||
@ -74,6 +75,19 @@ Item {
|
|||||||
messageDialog.open()
|
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() {
|
function openWallet() {
|
||||||
if (!root.wallet || root.busy)
|
if (!root.wallet || root.busy)
|
||||||
return
|
return
|
||||||
@ -116,6 +130,14 @@ Item {
|
|||||||
function onRowsRemoved() { root.clampSelection() }
|
function onRowsRemoved() { root.clampSelection() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: root.wallet
|
||||||
|
ignoreUnknownSignals: true
|
||||||
|
|
||||||
|
function onWalletSyncStatusChanged() { root.handleSyncFailure() }
|
||||||
|
function onWalletSyncErrorChanged() { root.handleSyncFailure() }
|
||||||
|
}
|
||||||
|
|
||||||
onConnectedChanged: {
|
onConnectedChanged: {
|
||||||
if (!root.connected) {
|
if (!root.connected) {
|
||||||
root.selectedIndex = 0
|
root.selectedIndex = 0
|
||||||
|
|||||||
@ -14,6 +14,9 @@ Item {
|
|||||||
property bool isWalletOpen: false
|
property bool isWalletOpen: false
|
||||||
property bool walletExists: true
|
property bool walletExists: true
|
||||||
property string walletHome: "/wallet"
|
property string walletHome: "/wallet"
|
||||||
|
property string walletSyncStatus: "closed"
|
||||||
|
property string walletSyncError: ""
|
||||||
|
property bool deferOpen: false
|
||||||
property int openCalls: 0
|
property int openCalls: 0
|
||||||
property int createCalls: 0
|
property int createCalls: 0
|
||||||
property int publicAccountCalls: 0
|
property int publicAccountCalls: 0
|
||||||
@ -22,7 +25,12 @@ Item {
|
|||||||
|
|
||||||
function openExisting() {
|
function openExisting() {
|
||||||
openCalls++
|
openCalls++
|
||||||
isWalletOpen = true
|
if (deferOpen) {
|
||||||
|
walletSyncStatus = "opening"
|
||||||
|
} else {
|
||||||
|
isWalletOpen = true
|
||||||
|
walletSyncStatus = "ready"
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,6 +141,19 @@ Item {
|
|||||||
tryCompare(fixture.control, "connected", true)
|
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() {
|
function test_requiresSeedBackupAcknowledgement() {
|
||||||
const fixture = createControl({ walletExists: false }, [])
|
const fixture = createControl({ walletExists: false }, [])
|
||||||
mouseClick(findChild(fixture.control, "walletConnectButton"))
|
mouseClick(findChild(fixture.control, "walletConnectButton"))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user