feat(wallet): toggling `include/exclude from total balance` menu action
filters out assets/collectibles/activities entries. Fixed direction of transfers for `All accounts` selection on activity tab. Closes #14162 #14216
This commit is contained in:
parent
6ba0cdfafa
commit
3843b53cc0
|
@ -30,8 +30,12 @@ proc newController*(
|
|||
proc delete*(self: Controller) =
|
||||
discard
|
||||
|
||||
proc buildAllTokens*(self: Controller, addresses: seq[string]) =
|
||||
self.walletAccountService.buildAllTokens(addresses, store = true)
|
||||
|
||||
proc init*(self: Controller) =
|
||||
self.walletAccountService.buildAllTokens(self.walletAccountService.getWalletAddresses(), store = true)
|
||||
let walletAddresses = self.walletAccountService.getWalletAddresses()
|
||||
self.buildAllTokens(walletAddresses)
|
||||
discard
|
||||
|
||||
proc getChainIds*(self: Controller): seq[int] =
|
||||
|
|
|
@ -70,3 +70,6 @@ method getGroupedAccountAssetsDataSource*(self: Module): GroupedAccountAssetsDat
|
|||
return (
|
||||
getGroupedAccountsAssetsList: proc(): var seq[GroupedTokenItem] = self.controller.getGroupedAccountsAssetsList()
|
||||
)
|
||||
|
||||
method filterChanged*(self: Module, addresses: seq[string], chainIds: seq[int]) =
|
||||
self.controller.buildAllTokens(addresses)
|
||||
|
|
|
@ -23,13 +23,16 @@ proc `$`*(self: Filter): string =
|
|||
chainIds: {self.chainIds},
|
||||
)"""
|
||||
|
||||
proc setAddresses*(self: Filter, addresses: seq[string]) =
|
||||
self.addresses = addresses
|
||||
|
||||
proc setAddress*(self: Filter, address: string) =
|
||||
self.addresses = @[address]
|
||||
self.setAddresses(@[address])
|
||||
|
||||
proc removeAddress*(self: Filter, address: string) =
|
||||
if len(self.addresses) == 1 and self.addresses[0] == address:
|
||||
let accounts = self.controller.getWalletAccounts()
|
||||
self.addresses = @[accounts[0].address]
|
||||
self.setAddresses(@[accounts[0].address])
|
||||
return
|
||||
|
||||
let ind = self.addresses.find(address)
|
||||
|
|
|
@ -18,6 +18,9 @@ method isLoaded*(self: AccessInterface): bool {.base.} =
|
|||
method setFilterAddress*(self: AccessInterface, address: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method setFilterAllAddresses*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method updateCurrency*(self: AccessInterface, currency: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
|
|
|
@ -192,20 +192,32 @@ method updateCurrency*(self: Module, currency: string) =
|
|||
method getCurrentCurrency*(self: Module): string =
|
||||
self.controller.getCurrency()
|
||||
|
||||
method setTotalCurrencyBalance*(self: Module) =
|
||||
proc getWalletAddressesNotHidden(self: Module): seq[string] =
|
||||
let walletAccounts = self.controller.getWalletAccounts()
|
||||
var addresses = walletAccounts.filter(a => not a.hideFromTotalBalance).map(a => a.address)
|
||||
return walletAccounts.filter(a => not a.hideFromTotalBalance).map(a => a.address)
|
||||
|
||||
method setTotalCurrencyBalance*(self: Module) =
|
||||
let addresses = self.getWalletAddressesNotHidden()
|
||||
self.view.setTotalCurrencyBalance(self.controller.getTotalCurrencyBalance(addresses, self.filter.chainIds))
|
||||
|
||||
proc notifyFilterChanged(self: Module) =
|
||||
proc notifyModulesOnFilterChanged(self: Module) =
|
||||
self.overviewModule.filterChanged(self.filter.addresses, self.filter.chainIds)
|
||||
self.accountsModule.filterChanged(self.filter.addresses, self.filter.chainIds)
|
||||
self.sendModule.filterChanged(self.filter.addresses, self.filter.chainIds)
|
||||
self.activityController.globalFilterChanged(self.filter.addresses, self.filter.chainIds, self.filter.allChainsEnabled)
|
||||
self.allTokensModule.filterChanged(self.filter.addresses)
|
||||
self.view.setAddressFilters(self.filter.addresses.join(":"))
|
||||
if self.filter.addresses.len > 0:
|
||||
self.view.filterChanged(self.filter.addresses[0])
|
||||
self.allCollectiblesModule.refreshWalletAccounts()
|
||||
self.assetsModule.filterChanged(self.filter.addresses, self.filter.chainIds)
|
||||
|
||||
proc updateViewWithAddressFilterChanged(self: Module) =
|
||||
if self.overviewModule.getIsAllAccounts():
|
||||
self.view.filterChanged("")
|
||||
else:
|
||||
self.view.filterChanged(self.view.getAddressFilters())
|
||||
|
||||
proc notifyFilterChanged(self: Module) =
|
||||
self.updateViewWithAddressFilterChanged()
|
||||
self.notifyModulesOnFilterChanged()
|
||||
|
||||
method getCurrencyAmount*(self: Module, amount: float64, symbol: string): CurrencyAmount =
|
||||
return self.controller.getCurrencyAmount(amount, symbol)
|
||||
|
@ -218,7 +230,17 @@ proc setKeypairOperabilityForObservedAccount(self: Module, address: string) =
|
|||
self.view.setKeypairOperabilityForObservedAccount(keypair.getOperability())
|
||||
|
||||
method setFilterAddress*(self: Module, address: string) =
|
||||
self.setKeypairOperabilityForObservedAccount(address)
|
||||
self.filter.setAddress(address)
|
||||
self.overviewModule.setIsAllAccounts(false)
|
||||
self.view.setAddressFilters(address)
|
||||
self.notifyFilterChanged()
|
||||
|
||||
method setFilterAllAddresses*(self: Module) =
|
||||
self.view.setKeypairOperabilityForObservedAccount("")
|
||||
self.filter.setAddresses(self.getWalletAddressesNotHidden())
|
||||
self.view.setAddressFilters(self.filter.addresses.join(":"))
|
||||
self.overviewModule.setIsAllAccounts(true)
|
||||
self.notifyFilterChanged()
|
||||
|
||||
method load*(self: Module) =
|
||||
|
@ -249,7 +271,7 @@ method load*(self: Module) =
|
|||
self.notifyFilterChanged()
|
||||
self.events.on(SIGNAL_WALLET_ACCOUNT_TOKENS_REBUILT) do(e:Args):
|
||||
self.setTotalCurrencyBalance()
|
||||
self.notifyFilterChanged()
|
||||
# self.notifyFilterChanged()
|
||||
self.events.on(SIGNAL_TOKENS_PRICES_UPDATED) do(e:Args):
|
||||
self.setTotalCurrencyBalance()
|
||||
self.notifyFilterChanged()
|
||||
|
@ -285,6 +307,9 @@ method load*(self: Module) =
|
|||
let data = LocalPairingStatus(e)
|
||||
self.onLocalPairingStatusUpdate(data)
|
||||
self.events.on(SIGNAL_WALLET_ACCOUNT_HIDDEN_UPDATED) do(e: Args):
|
||||
if self.overviewModule.getIsAllAccounts():
|
||||
self.filter.setAddresses(self.getWalletAddressesNotHidden())
|
||||
self.view.setAddressFilters(self.filter.addresses.join(":"))
|
||||
self.notifyFilterChanged()
|
||||
self.setTotalCurrencyBalance()
|
||||
|
||||
|
@ -339,6 +364,7 @@ proc checkIfModuleDidLoad(self: Module) =
|
|||
let mnemonicBackedUp = self.controller.isMnemonicBackedUp()
|
||||
self.view.setData(signingPhrase, mnemonicBackedUp)
|
||||
self.setTotalCurrencyBalance()
|
||||
self.filter.setAddresses(self.getWalletAddressesNotHidden())
|
||||
self.filter.load()
|
||||
self.notifyFilterChanged()
|
||||
self.moduleLoaded = true
|
||||
|
|
|
@ -27,6 +27,9 @@ proc init*(self: Controller) =
|
|||
proc getWalletAccountsByAddresses*(self: Controller, addresses: seq[string]): seq[wallet_account_service.WalletAccountDto] =
|
||||
return self.walletAccountService.getAccountsByAddresses(addresses)
|
||||
|
||||
proc getWalletAccounts*(self: Controller): seq[wallet_account_service.WalletAccountDto] =
|
||||
return self.walletAccountService.getWalletAccounts()
|
||||
|
||||
proc getTotalCurrencyBalance*(self: Controller, addresses: seq[string], chainIds: seq[int]): float64 =
|
||||
return self.walletAccountService.getTotalCurrencyBalance(addresses, chainIds)
|
||||
|
||||
|
|
|
@ -19,3 +19,9 @@ method viewDidLoad*(self: AccessInterface) {.base.} =
|
|||
|
||||
method filterChanged*(self: AccessInterface, addresses: seq[string], chainIds: seq[int]) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method setIsAllAccounts*(self: AccessInterface, value: bool) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getIsAllAccounts*(self: AccessInterface): bool {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
|
|
@ -20,6 +20,7 @@ type
|
|||
view: View
|
||||
controller: Controller
|
||||
moduleLoaded: bool
|
||||
isAllAccounts: bool
|
||||
|
||||
proc newModule*(
|
||||
delegate: delegate_interface.AccessInterface,
|
||||
|
@ -33,6 +34,7 @@ proc newModule*(
|
|||
result.view = newView(result)
|
||||
result.controller = newController(result, walletAccountService, currencyService)
|
||||
result.moduleLoaded = false
|
||||
result.isAllAccounts = false
|
||||
|
||||
method delete*(self: Module) =
|
||||
self.view.delete
|
||||
|
@ -66,20 +68,40 @@ method filterChanged*(self: Module, addresses: seq[string], chainIds: seq[int])
|
|||
let walletAccounts = self.controller.getWalletAccountsByAddresses(addresses)
|
||||
let walletAccount = walletAccounts[0]
|
||||
let loading = walletAccounts[0].assetsLoading or self.controller.getTokensMarketValuesLoading()
|
||||
let isWatchOnlyAccount = walletAccount.walletType == "watch"
|
||||
let item = initItem(
|
||||
walletAccount.name,
|
||||
walletAccount.mixedCaseAddress,
|
||||
walletAccount.ens,
|
||||
loading,
|
||||
walletAccount.colorId,
|
||||
walletAccount.emoji,
|
||||
isWatchOnlyAccount=isWatchOnlyAccount,
|
||||
canSend=not isWatchOnlyAccount and (walletAccount.operable==AccountFullyOperable or walletAccount.operable==AccountPartiallyOperable)
|
||||
)
|
||||
self.view.setData(item)
|
||||
if self.isAllAccounts:
|
||||
let item = initItem(
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
loading,
|
||||
"",
|
||||
"",
|
||||
isWatchOnlyAccount=false,
|
||||
isAllAccounts=true,
|
||||
self.getWalletAccoutColors(walletAccounts)
|
||||
)
|
||||
self.view.setData(item)
|
||||
else:
|
||||
let isWatchOnlyAccount = walletAccount.walletType == "watch"
|
||||
let item = initItem(
|
||||
walletAccount.name,
|
||||
walletAccount.mixedCaseAddress,
|
||||
walletAccount.ens,
|
||||
loading,
|
||||
walletAccount.colorId,
|
||||
walletAccount.emoji,
|
||||
isWatchOnlyAccount=isWatchOnlyAccount,
|
||||
canSend=not isWatchOnlyAccount and (walletAccount.operable==AccountFullyOperable or walletAccount.operable==AccountPartiallyOperable)
|
||||
)
|
||||
self.view.setData(item)
|
||||
|
||||
if loading:
|
||||
self.view.setCurrencyBalance(newCurrencyAmount())
|
||||
else:
|
||||
self.setBalance(addresses, chainIds)
|
||||
|
||||
method setIsAllAccounts(self: Module, value: bool) =
|
||||
self.isAllAccounts = value
|
||||
|
||||
method getIsAllAccounts(self: Module): bool =
|
||||
return self.isAllAccounts
|
||||
|
|
|
@ -94,7 +94,7 @@ QtObject:
|
|||
proc setAddressFilters*(self: View, address: string) =
|
||||
self.addressFilters = address
|
||||
self.addressFiltersChanged()
|
||||
proc getAddressFilters(self: View): string {.slot.} =
|
||||
proc getAddressFilters*(self: View): string {.slot.} =
|
||||
return self.addressFilters
|
||||
QtProperty[string] addressFilters:
|
||||
read = getAddressFilters
|
||||
|
@ -103,6 +103,9 @@ QtObject:
|
|||
proc setFilterAddress(self: View, address: string) {.slot.} =
|
||||
self.delegate.setFilterAddress(address)
|
||||
|
||||
proc setFilterAllAddresses*(self: View) {.slot.} =
|
||||
self.delegate.setFilterAllAddresses()
|
||||
|
||||
proc setTotalCurrencyBalance*(self: View, totalCurrencyBalance: CurrencyAmount) =
|
||||
self.totalCurrencyBalance = totalCurrencyBalance
|
||||
self.totalCurrencyBalanceChanged()
|
||||
|
|
|
@ -101,7 +101,7 @@ proc getWalletAccounts*(self: Service, excludeWatchOnly: bool = false): seq[Wall
|
|||
result.sort(walletAccountsCmp)
|
||||
|
||||
proc getWalletAddresses*(self: Service): seq[string] =
|
||||
return self.getWalletAccounts().map(a => a.address)
|
||||
return self.getWalletAccounts().filter(a => not a.hideFromTotalBalance).map(a => a.address)
|
||||
|
||||
proc updateAssetsLoadingState(self: Service, address: string, loading: bool) =
|
||||
var acc = self.getAccountByAddress(address)
|
||||
|
|
|
@ -96,7 +96,6 @@ proc buildAllTokens*(self: Service, accounts: seq[string], store: bool) =
|
|||
self.threadpool.start(arg)
|
||||
|
||||
proc getTotalCurrencyBalance*(self: Service, addresses: seq[string], chainIds: seq[int]): float64 =
|
||||
echo "+++++++ getTotalCurrencyBalance, addresses ", addresses, " chainIds: ", chainIds
|
||||
var totalBalance: float64 = 0.0
|
||||
for token in self.groupedAccountsTokensList:
|
||||
let price = self.tokenService.getPriceBySymbol(token.symbol)
|
||||
|
|
|
@ -70,9 +70,7 @@ Item {
|
|||
|
||||
d.displayAllAddresses()
|
||||
|
||||
if (rightPanelStackView.currentItem && !!rightPanelStackView.currentItem.resetView) {
|
||||
rightPanelStackView.currentItem.resetView()
|
||||
}
|
||||
d.resetRightPanelStackView()
|
||||
|
||||
if(!hideSignPhraseModal && !RootStore.hideSignPhraseModal){
|
||||
signPhrasePopup.open();
|
||||
|
@ -139,11 +137,13 @@ Item {
|
|||
function displayAllAddresses() {
|
||||
RootStore.showSavedAddresses = false
|
||||
RootStore.selectedAddress = ""
|
||||
RootStore.setFilterAllAddresses()
|
||||
}
|
||||
|
||||
function displayAddress(address) {
|
||||
RootStore.showSavedAddresses = false
|
||||
RootStore.selectedAddress = address
|
||||
d.resetRightPanelStackView() // Avoids crashing on asset items being destroyed while in signal handler
|
||||
RootStore.setFilterAddress(address)
|
||||
}
|
||||
|
||||
|
@ -151,6 +151,12 @@ Item {
|
|||
RootStore.showSavedAddresses = true
|
||||
RootStore.selectedAddress = ""
|
||||
}
|
||||
|
||||
function resetRightPanelStackView() {
|
||||
if (rightPanelStackView.currentItem && !!rightPanelStackView.currentItem.resetView) {
|
||||
rightPanelStackView.currentItem.resetView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SignPhraseModal {
|
||||
|
|
|
@ -234,6 +234,10 @@ QtObject {
|
|||
walletSection.setFilterAddress(address)
|
||||
}
|
||||
|
||||
function setFilterAllAddresses() {
|
||||
walletSectionInst.setFilterAllAddresses()
|
||||
}
|
||||
|
||||
function deleteAccount(address) {
|
||||
return walletSectionAccounts.deleteAccount(address)
|
||||
}
|
||||
|
|
|
@ -24,10 +24,8 @@ RightTabBaseView {
|
|||
signal launchShareAddressModal()
|
||||
|
||||
function resetView() {
|
||||
stack.currentIndex = 0
|
||||
resetStack()
|
||||
root.currentTabIndex = 0
|
||||
if (walletTabBar.currentIndex === 2)
|
||||
mainViewLoader.item.resetView()
|
||||
}
|
||||
|
||||
function resetStack() {
|
||||
|
@ -182,7 +180,7 @@ RightTabBaseView {
|
|||
RootStore.collectiblesStore.getDetailedCollectible(chainId, contractAddress, tokenId)
|
||||
RootStore.setCurrentViewedHolding(uid, tokenType)
|
||||
d.detailedCollectibleActivityController.resetFilter()
|
||||
d.detailedCollectibleActivityController.setFilterAddressesJson(JSON.stringify(RootStore.addressFilters.split(":")), RootStore.showAllAccounts)
|
||||
d.detailedCollectibleActivityController.setFilterAddressesJson(JSON.stringify(RootStore.addressFilters.split(":")))
|
||||
d.detailedCollectibleActivityController.setFilterChainsJson(JSON.stringify([chainId]), false)
|
||||
d.detailedCollectibleActivityController.setFilterCollectibles(JSON.stringify([uid]))
|
||||
d.detailedCollectibleActivityController.updateFilter()
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit a549529637b414621074c014d8411e9c189e484d
|
||||
Subproject commit 12deb2336028639ff11b6a3e08043e2961bed5c4
|
Loading…
Reference in New Issue