From daabef3a3c88f075e76a7214996afdbe9f6142c8 Mon Sep 17 00:00:00 2001 From: Eric Mastro Date: Thu, 22 Apr 2021 14:03:46 +1000 Subject: [PATCH] =?UTF-8?q?fix:=20do=20not=20show=20watch-only=20accounts?= =?UTF-8?q?=20as=20=E2=80=9Cfrom=20address=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: #2257. If a user had selected a watch-only address in the wallet, the backend `walletModel.currentAccount` property would also change. When loading a transaction modal, this property was used to set the `selectedAccount` value for the “from” `AccountSelector`, regardless if the account was a watch-only address. This PR updates the logic for `selectedAccount` such that it will only allow the account to be selected if it is not a watch-only account. --- .../Chat/ChatColumn/ChatComponents/ChatCommandModal.qml | 8 +++++++- .../AppLayouts/Profile/Sections/Ens/RegisterENSModal.qml | 8 +++++++- ui/app/AppLayouts/Profile/Sections/Ens/SetPubKeyModal.qml | 8 +++++++- ui/app/AppLayouts/Wallet/SendModal.qml | 8 +++++++- ui/shared/AccountSelector.qml | 5 +++-- ui/shared/status/StatusStickerPackPurchaseModal.qml | 8 +++++++- 6 files changed, 38 insertions(+), 7 deletions(-) diff --git a/ui/app/AppLayouts/Chat/ChatColumn/ChatComponents/ChatCommandModal.qml b/ui/app/AppLayouts/Chat/ChatColumn/ChatComponents/ChatCommandModal.qml index dcee6a195b..84b7d2f554 100644 --- a/ui/app/AppLayouts/Chat/ChatColumn/ChatComponents/ChatCommandModal.qml +++ b/ui/app/AppLayouts/Chat/ChatColumn/ChatComponents/ChatCommandModal.qml @@ -36,7 +36,13 @@ ModalPopup { AccountSelector { id: selectFromAccount accounts: walletModel.accounts - selectedAccount: walletModel.currentAccount + selectedAccount: { + const currAcc = walletModel.currentAccount + if (currAcc.walletType !== Constants.watchWalletType) { + return currAcc + } + return null + } currency: walletModel.defaultCurrency width: stack.width label: { diff --git a/ui/app/AppLayouts/Profile/Sections/Ens/RegisterENSModal.qml b/ui/app/AppLayouts/Profile/Sections/Ens/RegisterENSModal.qml index f585dba97d..6a9eac7f81 100644 --- a/ui/app/AppLayouts/Profile/Sections/Ens/RegisterENSModal.qml +++ b/ui/app/AppLayouts/Profile/Sections/Ens/RegisterENSModal.qml @@ -64,7 +64,13 @@ ModalPopup { AccountSelector { id: selectFromAccount accounts: walletModel.accounts - selectedAccount: walletModel.currentAccount + selectedAccount: { + const currAcc = walletModel.currentAccount + if (currAcc.walletType !== Constants.watchWalletType) { + return currAcc + } + return null + } currency: walletModel.defaultCurrency width: stack.width //% "Choose account" diff --git a/ui/app/AppLayouts/Profile/Sections/Ens/SetPubKeyModal.qml b/ui/app/AppLayouts/Profile/Sections/Ens/SetPubKeyModal.qml index 27dc3beb68..94453a158b 100644 --- a/ui/app/AppLayouts/Profile/Sections/Ens/SetPubKeyModal.qml +++ b/ui/app/AppLayouts/Profile/Sections/Ens/SetPubKeyModal.qml @@ -69,7 +69,13 @@ ModalPopup { AccountSelector { id: selectFromAccount accounts: walletModel.accounts - selectedAccount: walletModel.currentAccount + selectedAccount: { + const currAcc = walletModel.currentAccount + if (currAcc.walletType !== Constants.watchWalletType) { + return currAcc + } + return null + } currency: walletModel.defaultCurrency width: stack.width //% "Choose account" diff --git a/ui/app/AppLayouts/Wallet/SendModal.qml b/ui/app/AppLayouts/Wallet/SendModal.qml index 21a399d2da..7cbfea9b02 100644 --- a/ui/app/AppLayouts/Wallet/SendModal.qml +++ b/ui/app/AppLayouts/Wallet/SendModal.qml @@ -56,7 +56,13 @@ ModalPopup { AccountSelector { id: selectFromAccount accounts: walletModel.accounts - selectedAccount: walletModel.currentAccount + selectedAccount: { + const currAcc = walletModel.currentAccount + if (currAcc.walletType !== Constants.watchWalletType) { + return currAcc + } + return null + } currency: walletModel.defaultCurrency width: stack.width //% "From account" diff --git a/ui/shared/AccountSelector.qml b/ui/shared/AccountSelector.qml index 8f1b8d64bc..6c7942c803 100644 --- a/ui/shared/AccountSelector.qml +++ b/ui/shared/AccountSelector.qml @@ -2,6 +2,7 @@ import QtQuick 2.13 import QtQuick.Controls 2.13 import QtQuick.Layouts 1.13 import QtGraphicalEffects 1.13 +import QtQml.Models 2.14 import "../imports" import "../shared" import "../shared/status" @@ -187,7 +188,7 @@ Item { id: menuItem MenuItem { id: itemContainer - visible: walletType !== 'watch' + visible: walletType !== Constants.watchWalletType property bool isFirstItem: index === 0 property bool isLastItem: index === accounts.rowCount() - 1 @@ -197,7 +198,7 @@ Item { } } - height: walletType === 'watch' ? 0 : (accountName.height + 14 + accountAddress.height + 14) + height: walletType === Constants.watchWalletType ? 0 : (accountName.height + 14 + accountAddress.height + 14) SVGImage { id: iconImg anchors.left: parent.left diff --git a/ui/shared/status/StatusStickerPackPurchaseModal.qml b/ui/shared/status/StatusStickerPackPurchaseModal.qml index 65f0687fb8..94b375ca82 100644 --- a/ui/shared/status/StatusStickerPackPurchaseModal.qml +++ b/ui/shared/status/StatusStickerPackPurchaseModal.qml @@ -73,7 +73,13 @@ ModalPopup { AccountSelector { id: selectFromAccount accounts: walletModel.accounts - selectedAccount: walletModel.currentAccount + selectedAccount: { + const currAcc = walletModel.currentAccount + if (currAcc.walletType !== Constants.watchWalletType) { + return currAcc + } + return null + } currency: walletModel.defaultCurrency width: stack.width //% "Choose account"