From d05d743d80b5ab3602cc93afc13a063c6d622601 Mon Sep 17 00:00:00 2001 From: Cuteivist Date: Fri, 21 Jul 2023 12:55:36 +0200 Subject: [PATCH] fix(@desktop/wallet): Various wallet view fixes (#11606) --- .../modules/main/wallet_section/filter.nim | 1 - .../controls/SavedAddressesDelegate.qml | 6 ++-- .../Wallet/popups/TransactionAddressMenu.qml | 34 ++++--------------- .../AppLayouts/Wallet/views/LeftTabView.qml | 13 ++++--- .../Wallet/views/TransactionDetailView.qml | 1 + ui/imports/shared/stores/RootStore.qml | 5 +-- ui/imports/shared/views/HistoryView.qml | 6 ++-- ui/imports/utils/Constants.qml | 6 ++-- 8 files changed, 29 insertions(+), 43 deletions(-) diff --git a/src/app/modules/main/wallet_section/filter.nim b/src/app/modules/main/wallet_section/filter.nim index 32d009223c..f1cd30f86b 100644 --- a/src/app/modules/main/wallet_section/filter.nim +++ b/src/app/modules/main/wallet_section/filter.nim @@ -46,7 +46,6 @@ proc setAddress*(self: Filter, address: string) = self.addresses = @[address] proc removeAddress*(self: Filter, address: string) = - self.allAddresses = false if len(self.addresses) == 1 and self.addresses[0] == address: let accounts = self.controller.getWalletAccounts() self.addresses = @[accounts[0].address] diff --git a/ui/app/AppLayouts/Wallet/controls/SavedAddressesDelegate.qml b/ui/app/AppLayouts/Wallet/controls/SavedAddressesDelegate.qml index 1f5a222382..42faace038 100644 --- a/ui/app/AppLayouts/Wallet/controls/SavedAddressesDelegate.qml +++ b/ui/app/AppLayouts/Wallet/controls/SavedAddressesDelegate.qml @@ -174,7 +174,7 @@ StatusListItem { if (root.areTestNetworksEnabled) { baseUrl = Constants.networkExplorerLinks.goerliEtherscan } - Global.openLink("%1/address/%2".arg(baseUrl).arg(d.visibleAddress ? d.visibleAddress : root.ens)) + Global.openLink("%1/%2/%3".arg(baseUrl).arg(Constants.networkExplorerLinks.addressPath).arg(d.visibleAddress ? d.visibleAddress : root.ens)) } } @@ -187,7 +187,7 @@ StatusListItem { if (root.areTestNetworksEnabled) { baseUrl = Constants.networkExplorerLinks.goerliArbiscan } - Global.openLink("%1/address/%2".arg(baseUrl).arg(d.visibleAddress ? d.visibleAddress : root.ens)) + Global.openLink("%1/%2/%3".arg(baseUrl).arg(Constants.networkExplorerLinks.addressPath).arg(d.visibleAddress ? d.visibleAddress : root.ens)) } } StatusAction { @@ -199,7 +199,7 @@ StatusListItem { if (root.areTestNetworksEnabled) { baseUrl = Constants.networkExplorerLinks.goerliOptimistic } - Global.openLink("%1/address/%2".arg(baseUrl).arg(d.visibleAddress ? d.visibleAddress : root.ens)) + Global.openLink("%1/%2/%3".arg(baseUrl).arg(Constants.networkExplorerLinks.addressPath).arg(d.visibleAddress ? d.visibleAddress : root.ens)) } } StatusMenuSeparator { } diff --git a/ui/app/AppLayouts/Wallet/popups/TransactionAddressMenu.qml b/ui/app/AppLayouts/Wallet/popups/TransactionAddressMenu.qml index 5a268cbc8c..abcd3f1d71 100644 --- a/ui/app/AppLayouts/Wallet/popups/TransactionAddressMenu.qml +++ b/ui/app/AppLayouts/Wallet/popups/TransactionAddressMenu.qml @@ -19,6 +19,7 @@ StatusMenu { id: root property var contactsStore + property bool areTestNetworksEnabled: false signal openSendModal(address: string) @@ -42,8 +43,6 @@ StatusMenu { property string contractName: "" - property bool isGoerliTestnet: false - property int addressType: TransactionAddressMenu.AddressType.Address function getViewText(target) { @@ -68,11 +67,9 @@ StatusMenu { function refreshShowOnActionsVisiblity(shortChainName) { switch(shortChainName.toLowerCase()) { case Constants.networkShortChainNames.arbiscan.toLowerCase(): - case Constants.networkShortChainNames.goerliArbiscan.toLowerCase(): showOnArbiscanAction.enabled = true break case Constants.networkShortChainNames.optimism.toLowerCase(): - case Constants.networkShortChainNames.goerliOptimism.toLowerCase(): showOnOptimismAction.enabled = true break default: @@ -81,19 +78,6 @@ StatusMenu { } } - function refreshIsTestnet(shortChainName) { - switch(shortChainName.toLowerCase()) { - case Constants.networkShortChainNames.goerliMainnet.toLowerCase(): - case Constants.networkShortChainNames.goerliArbiscan.toLowerCase(): - case Constants.networkShortChainNames.goerliOptimism.toLowerCase(): - d.isGoerliTestnet = true - return - default: - d.isGoerliTestnet = false - return - } - } - function openMenu(delegate) { const x = delegate.width - 40 const y = delegate.height / 2 + 20 @@ -147,7 +131,6 @@ StatusMenu { d.addressName = contactData.isContact ? contactData.name : WalletStores.RootStore.getNameForAddress(address) d.addressEns = RootStore.getEnsForSavedWalletAddress(address) d.addressChains = RootStore.getChainShortNamesForSavedWalletAddress(address) - d.refreshIsTestnet(chainShortName) showOnEtherscanAction.enabled = true showOnArbiscanAction.enabled = address.includes(Constants.networkShortChainNames.arbiscan + ":") @@ -164,7 +147,6 @@ StatusMenu { d.addressType = TransactionAddressMenu.AddressType.Tx d.selectedAddress = address d.refreshShowOnActionsVisiblity(chainShortName) - d.refreshIsTestnet(chainShortName) d.openMenu(delegate) } @@ -173,7 +155,6 @@ StatusMenu { d.contractName = name d.selectedAddress = address d.refreshShowOnActionsVisiblity(chainShortName) - d.refreshIsTestnet(chainShortName) d.openMenu(delegate) } @@ -186,7 +167,6 @@ StatusMenu { onClosed: { d.addressType = TransactionAddressMenu.AddressType.Address d.contractName = "" - d.isGoerliTestnet = false showOnEtherscanAction.enabled = false showOnArbiscanAction.enabled = false @@ -207,8 +187,8 @@ StatusMenu { text: d.getViewText(qsTr("Etherscan")) icon.name: "link" onTriggered: { - const type = d.addressType === TransactionAddressMenu.Tx ? "tx" : "address" - const link = d.isGoerliTestnet ? Constants.networkExplorerLinks.goerliEtherscan : Constants.networkExplorerLinks.etherscan + const type = d.addressType === TransactionAddressMenu.Tx ? Constants.networkExplorerLinks.txPath : Constants.networkExplorerLinks.addressPath + const link = areTestNetworksEnabled ? Constants.networkExplorerLinks.goerliEtherscan : Constants.networkExplorerLinks.etherscan Global.openLink("%1/%2/%3".arg(link).arg(type).arg(d.selectedAddress)) } } @@ -218,8 +198,8 @@ StatusMenu { text: d.getViewText(qsTr("Arbiscan")) icon.name: "link" onTriggered: { - const type = d.addressType === TransactionAddressMenu.Tx ? "tx" : "address" - const link = d.isGoerliTestnet ? Constants.networkExplorerLinks.goerliArbiscan : Constants.networkExplorerLinks.arbiscan + const type = d.addressType === TransactionAddressMenu.Tx ? Constants.networkExplorerLinks.txPath : Constants.networkExplorerLinks.addressPath + const link = areTestNetworksEnabled ? Constants.networkExplorerLinks.goerliArbiscan : Constants.networkExplorerLinks.arbiscan Global.openLink("%1/%2/%3".arg(link).arg(type).arg(d.selectedAddress)) } } @@ -229,8 +209,8 @@ StatusMenu { text: d.getViewText(qsTr("Optimism Explorer")) icon.name: "link" onTriggered: { - const type = d.addressType === TransactionAddressMenu.Tx ? "tx" : "address" - const link = d.isGoerliTestnet ? Constants.networkExplorerLinks.goerliOptimistic : Constants.networkExplorerLinks.optimistic + const type = d.addressType === TransactionAddressMenu.Tx ? Constants.networkExplorerLinks.txPath : Constants.networkExplorerLinks.addressPath + const link = areTestNetworksEnabled ? Constants.networkExplorerLinks.goerliOptimistic : Constants.networkExplorerLinks.optimistic Global.openLink("%1/%2/%3".arg(link).arg(type).arg(d.selectedAddress)) } } diff --git a/ui/app/AppLayouts/Wallet/views/LeftTabView.qml b/ui/app/AppLayouts/Wallet/views/LeftTabView.qml index e3011faf8c..03eda58d10 100644 --- a/ui/app/AppLayouts/Wallet/views/LeftTabView.qml +++ b/ui/app/AppLayouts/Wallet/views/LeftTabView.qml @@ -207,8 +207,10 @@ Rectangle { Layout.fillWidth: true Layout.fillHeight: true Layout.topMargin: Style.current.halfPadding - - // ScrollBar.horizontal.policy: ScrollBar.AlwaysOff + currentIndex: -1 + highlightRangeMode: ListView.ApplyRange + preferredHighlightBegin: 0 + preferredHighlightEnd: height - (footerOverlayed ? footerItem.height : 0) readonly property Item firstItem: count > 0 ? itemAtIndex(0) : null @@ -217,6 +219,10 @@ Rectangle { readonly property bool itemLoaded: !model.assetsLoading // needed for e2e tests width: ListView.view.width - Style.current.padding * 2 highlighted: root.currentAddress.toLowerCase() === model.address.toLowerCase() + onHighlightedChanged: { + if (highlighted) + ListView.view.currentIndex = index + } anchors.horizontalCenter: !!parent ? parent.horizontalCenter : undefined title: model.name subTitle: LocaleUtils.currencyAmountToLocaleString(model.currencyBalance) @@ -281,6 +287,7 @@ Rectangle { cursorShape: Qt.PointingHandCursor onClicked: { root.showSavedAddresses = false + walletAccountsListView.currentIndex = -1 root.selectAllAccounts() } hoverEnabled: true @@ -406,10 +413,8 @@ Rectangle { model: SortFilterProxyModel { sourceModel: RootStore.accounts - sorters: RoleSorter { roleName: "position"; sortOrder: Qt.AscendingOrder } } - } } } diff --git a/ui/app/AppLayouts/Wallet/views/TransactionDetailView.qml b/ui/app/AppLayouts/Wallet/views/TransactionDetailView.qml index 9b18cd68dc..a7b4c10d59 100644 --- a/ui/app/AppLayouts/Wallet/views/TransactionDetailView.qml +++ b/ui/app/AppLayouts/Wallet/views/TransactionDetailView.qml @@ -678,6 +678,7 @@ Item { TransactionAddressMenu { id: addressMenu + areTestNetworksEnabled: WalletStores.RootStore.areTestNetworksEnabled contactsStore: root.contactsStore onOpenSendModal: (address) => root.sendModal.open(address) } diff --git a/ui/imports/shared/stores/RootStore.qml b/ui/imports/shared/stores/RootStore.qml index 62458b14da..fcdf23b318 100644 --- a/ui/imports/shared/stores/RootStore.qml +++ b/ui/imports/shared/stores/RootStore.qml @@ -40,7 +40,8 @@ QtObject { property var historyTransactions: Global.appIsReady? walletSection.activityController.model : null readonly property bool loadingHistoryTransactions: Global.appIsReady && walletSection.activityController.status.loadingData readonly property bool newDataAvailable: Global.appIsReady && walletSection.activityController.status.newDataAvailable - readonly property bool isTransactionFilterDirty: Global.appIsReady && walletSection.activityController.status.isFilterDirty + readonly property var transactionActivityStatus: Global.appIsReady ? walletSection.activityController.status : null + property bool isNonArchivalNode: history ? history.isNonArchivalNode : false property var marketValueStore: TokenMarketValuesStore{} @@ -188,7 +189,7 @@ QtObject { } function updateTransactionFilter() { - if (isTransactionFilterDirty) + if (transactionActivityStatus.isFilterDirty) walletSection.activityController.updateFilter() } diff --git a/ui/imports/shared/views/HistoryView.qml b/ui/imports/shared/views/HistoryView.qml index e8b56c6c33..c347acd852 100644 --- a/ui/imports/shared/views/HistoryView.qml +++ b/ui/imports/shared/views/HistoryView.qml @@ -31,15 +31,15 @@ ColumnLayout { signal launchTransactionDetail(var transaction) onVisibleChanged: { - if (visible && RootStore.isTransactionFilterDirty) { + if (visible && RootStore.transactionActivityStatus.isFilterDirty) { WalletStores.RootStore.currentActivityFiltersStore.applyAllFilters() } } Connections { - target: RootStore + target: RootStore.transactionActivityStatus enabled: root.visible - function onIsTransactionFilterDirtyChanged() { + function onIsFilterDirtyChanged() { RootStore.updateTransactionFilter() } } diff --git a/ui/imports/utils/Constants.qml b/ui/imports/utils/Constants.qml index a91cc1adc5..708274efe2 100644 --- a/ui/imports/utils/Constants.qml +++ b/ui/imports/utils/Constants.qml @@ -829,9 +829,6 @@ QtObject { readonly property string mainnet: "eth" readonly property string arbiscan: "arb" readonly property string optimism: "opt" - readonly property string goerliMainnet: "goEth" - readonly property string goerliArbiscan: "goArb" - readonly property string goerliOptimism: "goOpt" } readonly property QtObject networkExplorerLinks: QtObject { @@ -841,6 +838,9 @@ QtObject { readonly property string goerliEtherscan: "https://goerli.etherscan.io" readonly property string goerliArbiscan: "https://goerli.arbiscan.io" readonly property string goerliOptimistic: "https://goerli-optimism.etherscan.io" + + readonly property string addressPath: "address" + readonly property string txPath: "tx" } readonly property string api_request: "api-request"