From 94672b0e366e9cf29935c09ad7694b185127fe06 Mon Sep 17 00:00:00 2001 From: Alex Jbanca Date: Wed, 23 Oct 2024 15:56:32 +0300 Subject: [PATCH] fix(WC): Disable primary action buttons when the service is not available + Disable the `Connect` button after the first request --- ui/app/AppLayouts/Wallet/panels/DAppsWorkflow.qml | 2 ++ .../popups/walletconnect/ConnectDAppModal.qml | 15 ++++++++++++--- .../popups/walletconnect/DAppSignRequestModal.qml | 1 - 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ui/app/AppLayouts/Wallet/panels/DAppsWorkflow.qml b/ui/app/AppLayouts/Wallet/panels/DAppsWorkflow.qml index 47386a8f38..24253bc623 100644 --- a/ui/app/AppLayouts/Wallet/panels/DAppsWorkflow.qml +++ b/ui/app/AppLayouts/Wallet/panels/DAppsWorkflow.qml @@ -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: { diff --git a/ui/imports/shared/popups/walletconnect/ConnectDAppModal.qml b/ui/imports/shared/popups/walletconnect/ConnectDAppModal.qml index 89b480f016..6263c59388 100644 --- a/ui/imports/shared/popups/walletconnect/ConnectDAppModal.qml +++ b/ui/imports/shared/popups/walletconnect/ConnectDAppModal.qml @@ -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,16 +184,21 @@ 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() + } } } } @@ -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 } } diff --git a/ui/imports/shared/popups/walletconnect/DAppSignRequestModal.qml b/ui/imports/shared/popups/walletconnect/DAppSignRequestModal.qml index 12b326ac69..79b481fd03 100644 --- a/ui/imports/shared/popups/walletconnect/DAppSignRequestModal.qml +++ b/ui/imports/shared/popups/walletconnect/DAppSignRequestModal.qml @@ -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 {