fix(WC): Disable primary action buttons when the service is not available

+ Disable the `Connect` button after the first request
This commit is contained in:
Alex Jbanca 2024-10-23 15:56:32 +03:00 committed by Alex Jbanca
parent 7d3cd5c7bf
commit 519bfaedfa
3 changed files with 14 additions and 4 deletions

View File

@ -241,6 +241,7 @@ DappsComboBox {
dAppUrl: connectDappLoader.dappUrl
dAppName: connectDappLoader.dappName
dAppIconUrl: connectDappLoader.dappIcon
connectButtonEnabled: root.enabled
onConnect: {
if (!selectedAccount || !selectedAccount.address) {
@ -327,6 +328,7 @@ DappsComboBox {
enoughFundsForTransaction: request.haveEnoughFunds
enoughFundsForFees: request.haveEnoughFees
signButtonEnabled: ((!hasFees) || enoughFundsForTransaction && enoughFundsForFees) && root.enabled
signingTransaction: !!request.method && (request.method === SessionRequest.methods.signTransaction.name
|| request.method === SessionRequest.methods.sendTransaction.name)
requestPayload: {

View File

@ -62,6 +62,7 @@ StatusDialog {
property alias dAppName: dappCard.name
property alias dAppIconUrl: dappCard.iconUrl
property alias connectionStatus: d.connectionStatus
property bool connectButtonEnabled: true
/*
Selected account address holds the initial account address selection for the account selector.
@ -79,9 +80,11 @@ StatusDialog {
readonly property int connectionFailedStatus: 2
function pairSuccessful() {
d.connectionInProgress = false
d.connectionStatus = root.connectionSuccessfulStatus
}
function pairFailed() {
d.connectionInProgress = false
d.connectionStatus = root.connectionFailedStatus
}
@ -181,20 +184,25 @@ StatusDialog {
height: 44
text: d.connectionAttempted ? qsTr("Close") : qsTr("Connect")
enabled: {
if (d.connectionInProgress)
return false
if (!d.connectionAttempted)
return root.selectedChains.length > 0
return true
return root.connectButtonEnabled
}
onClicked: {
if (!d.connectionAttempted)
if (!d.connectionAttempted) {
d.connectionInProgress = true
root.connect()
else
}
else {
root.close()
}
}
}
}
}
QtObject {
id: d
@ -219,5 +227,6 @@ StatusDialog {
readonly property bool connectionSuccessful: d.connectionStatus === root.connectionSuccessfulStatus
readonly property bool connectionFailed: d.connectionStatus === root.connectionFailedStatus
readonly property bool connectionAttempted: d.connectionStatus !== root.notConnectedStatus
property bool connectionInProgress: false
}
}

View File

@ -42,7 +42,6 @@ SignTransactionModalBase {
property bool enoughFundsForTransaction: true
property bool enoughFundsForFees: false
signButtonEnabled: (!hasFees) || enoughFundsForTransaction && enoughFundsForFees
title: qsTr("Sign Request")
subtitle: SQUtils.StringUtils.extractDomainFromLink(root.dappUrl)
headerIconComponent: RoundImageWithBadge {