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
parent 78c131f19f
commit 94672b0e36
No known key found for this signature in database
GPG Key ID: 6004079575C21C5D
3 changed files with 14 additions and 4 deletions

View File

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

View File

@ -62,6 +62,7 @@ StatusDialog {
property alias dAppName: dappCard.name property alias dAppName: dappCard.name
property alias dAppIconUrl: dappCard.iconUrl property alias dAppIconUrl: dappCard.iconUrl
property alias connectionStatus: d.connectionStatus property alias connectionStatus: d.connectionStatus
property bool connectButtonEnabled: true
/* /*
Selected account address holds the initial account address selection for the account selector. Selected account address holds the initial account address selection for the account selector.
@ -79,9 +80,11 @@ StatusDialog {
readonly property int connectionFailedStatus: 2 readonly property int connectionFailedStatus: 2
function pairSuccessful() { function pairSuccessful() {
d.connectionInProgress = false
d.connectionStatus = root.connectionSuccessfulStatus d.connectionStatus = root.connectionSuccessfulStatus
} }
function pairFailed() { function pairFailed() {
d.connectionInProgress = false
d.connectionStatus = root.connectionFailedStatus d.connectionStatus = root.connectionFailedStatus
} }
@ -181,16 +184,21 @@ StatusDialog {
height: 44 height: 44
text: d.connectionAttempted ? qsTr("Close") : qsTr("Connect") text: d.connectionAttempted ? qsTr("Close") : qsTr("Connect")
enabled: { enabled: {
if (d.connectionInProgress)
return false
if (!d.connectionAttempted) if (!d.connectionAttempted)
return root.selectedChains.length > 0 return root.selectedChains.length > 0
return true return root.connectButtonEnabled
} }
onClicked: { onClicked: {
if (!d.connectionAttempted) if (!d.connectionAttempted) {
d.connectionInProgress = true
root.connect() root.connect()
else }
else {
root.close() root.close()
}
} }
} }
} }
@ -219,5 +227,6 @@ StatusDialog {
readonly property bool connectionSuccessful: d.connectionStatus === root.connectionSuccessfulStatus readonly property bool connectionSuccessful: d.connectionStatus === root.connectionSuccessfulStatus
readonly property bool connectionFailed: d.connectionStatus === root.connectionFailedStatus readonly property bool connectionFailed: d.connectionStatus === root.connectionFailedStatus
readonly property bool connectionAttempted: d.connectionStatus !== root.notConnectedStatus 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 enoughFundsForTransaction: true
property bool enoughFundsForFees: false property bool enoughFundsForFees: false
signButtonEnabled: (!hasFees) || enoughFundsForTransaction && enoughFundsForFees
title: qsTr("Sign Request") title: qsTr("Sign Request")
subtitle: SQUtils.StringUtils.extractDomainFromLink(root.dappUrl) subtitle: SQUtils.StringUtils.extractDomainFromLink(root.dappUrl)
headerIconComponent: RoundImageWithBadge { headerIconComponent: RoundImageWithBadge {