From a4a2ca4e9c6046db4429e63c1e54ead291bb9cd8 Mon Sep 17 00:00:00 2001 From: Khushboo Mehta Date: Wed, 24 May 2023 14:11:12 +0200 Subject: [PATCH] fix(@desktop/wallet): Wallet Footer for watch only accounts should show only "Receive" as an option fixes #10786 --- src/app/modules/main/wallet_section/overview/item.nim | 6 ++++++ .../modules/main/wallet_section/overview/module.nim | 2 ++ src/app/modules/main/wallet_section/overview/view.nim | 11 +++++++++++ ui/app/AppLayouts/Wallet/panels/WalletFooter.qml | 2 ++ 4 files changed, 21 insertions(+) diff --git a/src/app/modules/main/wallet_section/overview/item.nim b/src/app/modules/main/wallet_section/overview/item.nim index 5b0f6952fc..70d693b880 100644 --- a/src/app/modules/main/wallet_section/overview/item.nim +++ b/src/app/modules/main/wallet_section/overview/item.nim @@ -8,6 +8,7 @@ type balanceLoading: bool color: string emoji: string + isWatchOnlyAccount: bool isAllAccounts: bool hideWatchAccounts: bool colors: seq[string] @@ -19,6 +20,7 @@ proc initItem*( balanceLoading: bool = true, color: string, emoji: string, + isWatchOnlyAccount: bool=false, isAllAccounts: bool = false, hideWatchAccounts: bool = false, colors: seq[string] = @[] @@ -32,6 +34,7 @@ proc initItem*( result.isAllAccounts = isAllAccounts result.hideWatchAccounts = hideWatchAccounts result.colors = colors + result.isWatchOnlyAccount = isWatchOnlyAccount proc `$`*(self: Item): string = result = fmt"""OverviewItem( @@ -41,6 +44,7 @@ proc `$`*(self: Item): string = balanceLoading: {self.balanceLoading}, color: {self.color}, emoji: {self.emoji}, + isWatchOnlyAccount: {self.isWatchOnlyAccount}, isAllAccounts: {self.isAllAccounts}, hideWatchAccounts: {self.hideWatchAccounts}, colors: {self.colors} @@ -78,3 +82,5 @@ proc getColors*(self: Item): string = result = result & ";" & color return result +proc getIsWatchOnlyAccount*(self: Item): bool = + return self.isWatchOnlyAccount diff --git a/src/app/modules/main/wallet_section/overview/module.nim b/src/app/modules/main/wallet_section/overview/module.nim index 2b8495dda8..5ee83a3762 100644 --- a/src/app/modules/main/wallet_section/overview/module.nim +++ b/src/app/modules/main/wallet_section/overview/module.nim @@ -75,6 +75,7 @@ method filterChanged*(self: Module, addresses: seq[string], chainIds: seq[int], walletAccounts[0].assetsLoading, "", "", + isWatchOnlyAccount=false, isAllAccounts=true, hideWatchAccounts=excludeWatchOnly, self.getWalletAccoutColors(walletAccounts) @@ -89,6 +90,7 @@ method filterChanged*(self: Module, addresses: seq[string], chainIds: seq[int], walletAccount.assetsLoading, walletAccount.color, walletAccount.emoji, + isWatchOnlyAccount=walletAccount.walletType == "watch" ) self.view.setData(item) diff --git a/src/app/modules/main/wallet_section/overview/view.nim b/src/app/modules/main/wallet_section/overview/view.nim index 004de0ddc7..00bbca7fa7 100644 --- a/src/app/modules/main/wallet_section/overview/view.nim +++ b/src/app/modules/main/wallet_section/overview/view.nim @@ -19,6 +19,7 @@ QtObject: isAllAccounts: bool hideWatchAccounts: bool colors: string + isWatchOnlyAccount: bool proc setup(self: View) = self.QObject.setup @@ -112,6 +113,13 @@ QtObject: read = getColors notify = colorsChanged + proc getIsWatchOnlyAccount(self: View): QVariant {.slot.} = + return newQVariant(self.isWatchOnlyAccount) + proc isWatchOnlyAccountChanged(self: View) {.signal.} + QtProperty[QVariant] isWatchOnlyAccount: + read = getIsWatchOnlyAccount + notify = isWatchOnlyAccountChanged + proc setData*(self: View, item: Item) = if(self.name != item.getName()): self.name = item.getName() @@ -129,6 +137,9 @@ QtObject: if(self.emoji != item.getEmoji()): self.emoji = item.getEmoji() self.emojiChanged() + if(self.isWatchOnlyAccount != item.getIsWatchOnlyAccount()): + self.isWatchOnlyAccount = item.getIsWatchOnlyAccount() + self.isWatchOnlyAccountChanged() if(self.isAllAccounts != item.getIsAllAccounts()): self.isAllAccounts = item.getIsAllAccounts() self.isAllAccountsChanged() diff --git a/ui/app/AppLayouts/Wallet/panels/WalletFooter.qml b/ui/app/AppLayouts/Wallet/panels/WalletFooter.qml index eab690da31..7b9b032b36 100644 --- a/ui/app/AppLayouts/Wallet/panels/WalletFooter.qml +++ b/ui/app/AppLayouts/Wallet/panels/WalletFooter.qml @@ -44,6 +44,7 @@ Rectangle { sendModal.open() } tooltipText: networkConnectionStore.sendBuyBridgeToolTipText + visible: !walletStore.overview.isWatchOnlyAccount } StatusFlatButton { @@ -64,6 +65,7 @@ Rectangle { sendModal.open() } tooltipText: networkConnectionStore.sendBuyBridgeToolTipText + visible: !walletStore.overview.isWatchOnlyAccount } StatusFlatButton {