fix: do not show watch-only accounts as “from address”
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.
This commit is contained in:
parent
3a7c95967a
commit
daabef3a3c
|
@ -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: {
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue