mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-07-16 11:59:29 +00:00
fix(apps/amm): surface wallet action failures
This commit is contained in:
parent
340000f068
commit
e8c70fb2a5
@ -97,6 +97,20 @@ Item {
|
|||||||
clipboardProxy.text = ""
|
clipboardProxy.text = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function showWalletMessage(title, message) {
|
||||||
|
walletMessageDialog.title = title
|
||||||
|
walletMessageDialog.message = message
|
||||||
|
walletMessageDialog.open()
|
||||||
|
}
|
||||||
|
|
||||||
|
function finishAccountCreation(accountId, fallbackError) {
|
||||||
|
createAccountDialog.busy = false
|
||||||
|
if (accountId && accountId.length > 0)
|
||||||
|
createAccountDialog.close()
|
||||||
|
else
|
||||||
|
createAccountDialog.createError = fallbackError
|
||||||
|
}
|
||||||
|
|
||||||
implicitWidth: root.connected ? connectedButton.width : connectButton.width
|
implicitWidth: root.connected ? connectedButton.width : connectButton.width
|
||||||
implicitHeight: 40
|
implicitHeight: 40
|
||||||
|
|
||||||
@ -113,8 +127,17 @@ Item {
|
|||||||
// Re-open an existing wallet; only show the create modal on first run.
|
// Re-open an existing wallet; only show the create modal on first run.
|
||||||
if (root.backend && root.backend.walletExists)
|
if (root.backend && root.backend.walletExists)
|
||||||
logos.watch(root.backend.openExisting(),
|
logos.watch(root.backend.openExisting(),
|
||||||
function(ok) { if (!ok) console.warn("openExisting failed") },
|
function(ok) {
|
||||||
function(error) { console.warn("openExisting error:", error) })
|
if (!ok)
|
||||||
|
root.showWalletMessage(
|
||||||
|
qsTr("Unable to connect wallet"),
|
||||||
|
qsTr("The existing wallet could not be opened. Check the wallet files and try again."))
|
||||||
|
},
|
||||||
|
function(error) {
|
||||||
|
root.showWalletMessage(
|
||||||
|
qsTr("Unable to connect wallet"),
|
||||||
|
qsTr("Error opening wallet: %1").arg(error))
|
||||||
|
})
|
||||||
else
|
else
|
||||||
createWalletDialog.open()
|
createWalletDialog.open()
|
||||||
}
|
}
|
||||||
@ -490,16 +513,38 @@ Item {
|
|||||||
CreateAccountDialog {
|
CreateAccountDialog {
|
||||||
id: createAccountDialog
|
id: createAccountDialog
|
||||||
onCreatePublicRequested: {
|
onCreatePublicRequested: {
|
||||||
if (!root.backend) return
|
if (!root.backend) {
|
||||||
|
root.finishAccountCreation("", qsTr("Wallet backend is unavailable. Reconnect and try again."))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
createAccountDialog.createError = ""
|
||||||
logos.watch(root.backend.createAccountPublic(),
|
logos.watch(root.backend.createAccountPublic(),
|
||||||
function(_id) { /* model updates via NOTIFY after refresh */ },
|
function(id) {
|
||||||
function(error) { console.warn("createAccountPublic failed:", error) })
|
root.finishAccountCreation(id, qsTr("Failed to create account. Please try again."))
|
||||||
|
},
|
||||||
|
function(error) {
|
||||||
|
createAccountDialog.busy = false
|
||||||
|
createAccountDialog.createError = qsTr("Error creating account: %1").arg(error)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
onCreatePrivateRequested: {
|
onCreatePrivateRequested: {
|
||||||
if (!root.backend) return
|
if (!root.backend) {
|
||||||
|
root.finishAccountCreation("", qsTr("Wallet backend is unavailable. Reconnect and try again."))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
createAccountDialog.createError = ""
|
||||||
logos.watch(root.backend.createAccountPrivate(),
|
logos.watch(root.backend.createAccountPrivate(),
|
||||||
function(_id) { /* model updates via NOTIFY after refresh */ },
|
function(id) {
|
||||||
function(error) { console.warn("createAccountPrivate failed:", error) })
|
root.finishAccountCreation(id, qsTr("Failed to create private account. Please try again."))
|
||||||
|
},
|
||||||
|
function(error) {
|
||||||
|
createAccountDialog.busy = false
|
||||||
|
createAccountDialog.createError = qsTr("Error creating private account: %1").arg(error)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WalletMessageDialog {
|
||||||
|
id: walletMessageDialog
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,13 +9,18 @@ import Logos.Controls
|
|||||||
Popup {
|
Popup {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
property string createError: ""
|
||||||
|
property bool busy: false
|
||||||
|
|
||||||
signal createPublicRequested()
|
signal createPublicRequested()
|
||||||
signal createPrivateRequested()
|
signal createPrivateRequested()
|
||||||
|
|
||||||
modal: true
|
modal: true
|
||||||
dim: true
|
dim: true
|
||||||
padding: Theme.spacing.large
|
padding: Theme.spacing.large
|
||||||
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
|
closePolicy: root.busy
|
||||||
|
? Popup.NoAutoClose
|
||||||
|
: (Popup.CloseOnEscape | Popup.CloseOnPressOutside)
|
||||||
|
|
||||||
// Center on the full-window overlay rather than the small navbar control
|
// Center on the full-window overlay rather than the small navbar control
|
||||||
// this popup is declared inside.
|
// this popup is declared inside.
|
||||||
@ -23,6 +28,11 @@ Popup {
|
|||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
width: 360
|
width: 360
|
||||||
|
|
||||||
|
onOpened: {
|
||||||
|
root.createError = ""
|
||||||
|
root.busy = false
|
||||||
|
}
|
||||||
|
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
color: Theme.palette.backgroundSecondary
|
color: Theme.palette.backgroundSecondary
|
||||||
radius: Theme.spacing.radiusXlarge
|
radius: Theme.spacing.radiusXlarge
|
||||||
@ -74,9 +84,19 @@ Popup {
|
|||||||
LogosSwitch {
|
LogosSwitch {
|
||||||
id: privateSwitch
|
id: privateSwitch
|
||||||
checked: false
|
checked: false
|
||||||
|
enabled: !root.busy
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LogosText {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
visible: root.createError.length > 0
|
||||||
|
text: root.createError
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
font.pixelSize: Theme.typography.secondaryText
|
||||||
|
color: Theme.palette.error
|
||||||
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
Layout.topMargin: Theme.spacing.medium
|
Layout.topMargin: Theme.spacing.medium
|
||||||
spacing: Theme.spacing.medium
|
spacing: Theme.spacing.medium
|
||||||
@ -84,17 +104,20 @@ Popup {
|
|||||||
LogosButton {
|
LogosButton {
|
||||||
text: qsTr("Cancel")
|
text: qsTr("Cancel")
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
enabled: !root.busy
|
||||||
onClicked: root.close()
|
onClicked: root.close()
|
||||||
}
|
}
|
||||||
LogosButton {
|
LogosButton {
|
||||||
text: qsTr("Create")
|
text: root.busy ? qsTr("Creating...") : qsTr("Create")
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
enabled: !root.busy
|
||||||
onClicked: {
|
onClicked: {
|
||||||
|
root.createError = ""
|
||||||
|
root.busy = true
|
||||||
if (privateSwitch.checked)
|
if (privateSwitch.checked)
|
||||||
root.createPrivateRequested()
|
root.createPrivateRequested()
|
||||||
else
|
else
|
||||||
root.createPublicRequested()
|
root.createPublicRequested()
|
||||||
root.close()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
58
apps/amm/qml/components/wallet/WalletMessageDialog.qml
Normal file
58
apps/amm/qml/components/wallet/WalletMessageDialog.qml
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
import QtQuick
|
||||||
|
import QtQuick.Controls
|
||||||
|
import QtQuick.Layouts
|
||||||
|
|
||||||
|
import Logos.Theme
|
||||||
|
import Logos.Controls
|
||||||
|
|
||||||
|
Popup {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
property string title: qsTr("Wallet error")
|
||||||
|
property string message: ""
|
||||||
|
property string acceptLabel: qsTr("OK")
|
||||||
|
|
||||||
|
modal: true
|
||||||
|
dim: true
|
||||||
|
padding: Theme.spacing.large
|
||||||
|
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
|
||||||
|
|
||||||
|
parent: Overlay.overlay
|
||||||
|
anchors.centerIn: parent
|
||||||
|
width: 360
|
||||||
|
|
||||||
|
background: Rectangle {
|
||||||
|
color: Theme.palette.backgroundSecondary
|
||||||
|
radius: Theme.spacing.radiusXlarge
|
||||||
|
border.color: Theme.palette.backgroundElevated
|
||||||
|
}
|
||||||
|
|
||||||
|
contentItem: ColumnLayout {
|
||||||
|
width: root.availableWidth
|
||||||
|
spacing: Theme.spacing.large
|
||||||
|
|
||||||
|
LogosText {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
text: root.title
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
font.pixelSize: Theme.typography.titleText
|
||||||
|
font.weight: Theme.typography.weightBold
|
||||||
|
color: Theme.palette.text
|
||||||
|
}
|
||||||
|
|
||||||
|
LogosText {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
text: root.message
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
font.pixelSize: Theme.typography.secondaryText
|
||||||
|
color: Theme.palette.textSecondary
|
||||||
|
}
|
||||||
|
|
||||||
|
LogosButton {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.topMargin: Theme.spacing.medium
|
||||||
|
text: root.acceptLabel
|
||||||
|
onClicked: root.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user