From 007f75ad4c4823692abf9c12ee7c1a0806a87659 Mon Sep 17 00:00:00 2001 From: Alex Jbanca Date: Thu, 5 Dec 2024 19:19:33 +0200 Subject: [PATCH] fix(dapps): Detach the pairInstructions popup from the pairing popup closes #16887 The pairing popup can be destroyed while the pairInstructions popup is active. As a result the pair instructions popup will misbehave. To fix this, the pair instructions component is moved outside of the pair popup scope --- .../Wallet/popups/dapps/DAppsWorkflow.qml | 16 ++++++++++++++++ .../Wallet/services/dapps/DAppsService.qml | 8 ++++++-- .../shared/popups/walletconnect/PairWCModal.qml | 8 ++------ 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/ui/app/AppLayouts/Wallet/popups/dapps/DAppsWorkflow.qml b/ui/app/AppLayouts/Wallet/popups/dapps/DAppsWorkflow.qml index 7329b843ee..92ccbbcff2 100644 --- a/ui/app/AppLayouts/Wallet/popups/dapps/DAppsWorkflow.qml +++ b/ui/app/AppLayouts/Wallet/popups/dapps/DAppsWorkflow.qml @@ -173,6 +173,22 @@ SQUtils.QObject { onClosed: pairWCLoader.active = false onPair: (uri) => root.pairingRequested(uri) onPairUriChanged: (uri) => root.pairingValidationRequested(uri) + onPairInstructionsRequested: pairInstructionsLoader.active = true + } + } + + Loader { + id: pairInstructionsLoader + + active: false + parent: root.visualParent + + sourceComponent: Component { + DAppsUriCopyInstructionsPopup{ + visible: true + destroyOnClose: false + onClosed: pairInstructionsLoader.active = false + } } } diff --git a/ui/app/AppLayouts/Wallet/services/dapps/DAppsService.qml b/ui/app/AppLayouts/Wallet/services/dapps/DAppsService.qml index 9b67c501ef..76db4a8d33 100644 --- a/ui/app/AppLayouts/Wallet/services/dapps/DAppsService.qml +++ b/ui/app/AppLayouts/Wallet/services/dapps/DAppsService.qml @@ -72,6 +72,7 @@ SQUtils.QObject { /// Validates the pairing URI function validatePairingUri(uri) { + timeoutTimer.start() d.validatePairingUri(uri) } @@ -190,14 +191,17 @@ SQUtils.QObject { root.pairingValidated(state) } - function onPairingResponse(key, state) { - timeoutTimer.stop() + function onPairingResponse(state) { if (state != Pairing.errors.uriOk) { d.reportPairErrorState(state) + return } + + timeoutTimer.restart() } function onConnectDApp(dappChains, dappUrl, dappName, dappIcon, connectorId, key) { + timeoutTimer.stop() const connectorIcon = Constants.dappImageByType[connectorId] root.connectDApp(dappChains, dappUrl, dappName, dappIcon, connectorIcon, key) } diff --git a/ui/imports/shared/popups/walletconnect/PairWCModal.qml b/ui/imports/shared/popups/walletconnect/PairWCModal.qml index 5c995c9598..f63338301c 100644 --- a/ui/imports/shared/popups/walletconnect/PairWCModal.qml +++ b/ui/imports/shared/popups/walletconnect/PairWCModal.qml @@ -36,6 +36,7 @@ StatusDialog { signal pair(string uri) signal pairUriChanged(string uri) + signal pairInstructionsRequested() closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside @@ -72,12 +73,7 @@ StatusDialog { normalColor: linkColor onClicked: { - Global.openPopup(uriCopyInstructionsPopup) - } - - Component { - id: uriCopyInstructionsPopup - DAppsUriCopyInstructionsPopup{} + root.pairInstructionsRequested() } } }