fix(wallet) use the all chains enabled state in filter
Optimization and fixes no chain ID for multi-transaction issue. Updates: #12077
This commit is contained in:
parent
a8cb40809c
commit
dfb76cfa87
|
@ -53,6 +53,7 @@ QtObject:
|
||||||
addresses: seq[string]
|
addresses: seq[string]
|
||||||
# call updateAssetsIdentities after updating chainIds
|
# call updateAssetsIdentities after updating chainIds
|
||||||
chainIds: seq[int]
|
chainIds: seq[int]
|
||||||
|
allChainsSelected: bool
|
||||||
|
|
||||||
requestId: int32
|
requestId: int32
|
||||||
|
|
||||||
|
@ -152,7 +153,8 @@ QtObject:
|
||||||
self.eventsHandler.updateSubscribedChainIDs(self.chainIds)
|
self.eventsHandler.updateSubscribedChainIDs(self.chainIds)
|
||||||
self.status.setNewDataAvailable(false)
|
self.status.setNewDataAvailable(false)
|
||||||
|
|
||||||
let response = backend_activity.filterActivityAsync(self.requestId, self.addresses, seq[backend_activity.ChainId](self.chainIds), self.currentActivityFilter, 0, FETCH_BATCH_COUNT_DEFAULT)
|
let chains = if not self.allChainsSelected: self.chainIds else: @[]
|
||||||
|
let response = backend_activity.filterActivityAsync(self.requestId, self.addresses, seq[backend_activity.ChainId](chains), self.currentActivityFilter, 0, FETCH_BATCH_COUNT_DEFAULT)
|
||||||
if response.error != nil:
|
if response.error != nil:
|
||||||
error "error fetching activity entries: ", response.error
|
error "error fetching activity entries: ", response.error
|
||||||
self.status.setLoadingData(false)
|
self.status.setLoadingData(false)
|
||||||
|
@ -160,7 +162,8 @@ QtObject:
|
||||||
|
|
||||||
proc loadMoreItems(self: Controller) {.slot.} =
|
proc loadMoreItems(self: Controller) {.slot.} =
|
||||||
self.status.setLoadingData(true)
|
self.status.setLoadingData(true)
|
||||||
let response = backend_activity.filterActivityAsync(self.requestId, self.addresses, seq[backend_activity.ChainId](self.chainIds), self.currentActivityFilter, self.model.getCount(), FETCH_BATCH_COUNT_DEFAULT)
|
let chains = if not self.allChainsSelected: self.chainIds else: @[]
|
||||||
|
let response = backend_activity.filterActivityAsync(self.requestId, self.addresses, seq[backend_activity.ChainId](chains), self.currentActivityFilter, self.model.getCount(), FETCH_BATCH_COUNT_DEFAULT)
|
||||||
if response.error != nil:
|
if response.error != nil:
|
||||||
self.status.setLoadingData(false)
|
self.status.setLoadingData(false)
|
||||||
error "error fetching activity entries: ", response.error
|
error "error fetching activity entries: ", response.error
|
||||||
|
@ -255,6 +258,7 @@ QtObject:
|
||||||
|
|
||||||
result.addresses = @[]
|
result.addresses = @[]
|
||||||
result.chainIds = @[]
|
result.chainIds = @[]
|
||||||
|
result.allChainsSelected = true
|
||||||
|
|
||||||
result.setup()
|
result.setup()
|
||||||
|
|
||||||
|
@ -340,8 +344,9 @@ QtObject:
|
||||||
proc setFilterToAddresses*(self: Controller, addresses: seq[string]) =
|
proc setFilterToAddresses*(self: Controller, addresses: seq[string]) =
|
||||||
self.currentActivityFilter.counterpartyAddresses = addresses
|
self.currentActivityFilter.counterpartyAddresses = addresses
|
||||||
|
|
||||||
proc setFilterChains*(self: Controller, chainIds: seq[int]) =
|
proc setFilterChains*(self: Controller, chainIds: seq[int], allEnabled: bool) =
|
||||||
self.chainIds = chainIds
|
self.chainIds = chainIds
|
||||||
|
self.allChainsSelected = allEnabled
|
||||||
self.status.setIsFilterDirty(true)
|
self.status.setIsFilterDirty(true)
|
||||||
|
|
||||||
self.updateAssetsIdentities()
|
self.updateAssetsIdentities()
|
||||||
|
@ -379,11 +384,11 @@ QtObject:
|
||||||
QtProperty[QVariant] status:
|
QtProperty[QVariant] status:
|
||||||
read = getStatus
|
read = getStatus
|
||||||
|
|
||||||
proc globalFilterChanged*(self: Controller, addresses: seq[string], chainIds: seq[int]) =
|
proc globalFilterChanged*(self: Controller, addresses: seq[string], chainIds: seq[int], allChainsEnabled: bool) =
|
||||||
if (self.addresses == addresses and self.chainIds == chainIds):
|
if (self.addresses == addresses and self.chainIds == chainIds):
|
||||||
return
|
return
|
||||||
self.setFilterAddresses(addresses)
|
self.setFilterAddresses(addresses)
|
||||||
self.setFilterChains(chainIds)
|
self.setFilterChains(chainIds, allChainsEnabled)
|
||||||
|
|
||||||
proc noLimitTimestamp*(self: Controller): int {.slot.} =
|
proc noLimitTimestamp*(self: Controller): int {.slot.} =
|
||||||
return backend_activity.noLimitTimestampForPeriod
|
return backend_activity.noLimitTimestampForPeriod
|
||||||
|
|
|
@ -6,6 +6,7 @@ type Filter* = ref object
|
||||||
controller: controller.Controller
|
controller: controller.Controller
|
||||||
addresses*: seq[string]
|
addresses*: seq[string]
|
||||||
chainIds*: seq[int]
|
chainIds*: seq[int]
|
||||||
|
allChainsEnabled*: bool
|
||||||
allAddresses*: bool
|
allAddresses*: bool
|
||||||
|
|
||||||
proc initFilter*(
|
proc initFilter*(
|
||||||
|
@ -15,6 +16,7 @@ proc initFilter*(
|
||||||
result.controller = controller
|
result.controller = controller
|
||||||
result.addresses = @[]
|
result.addresses = @[]
|
||||||
result.chainIds = @[]
|
result.chainIds = @[]
|
||||||
|
result.allChainsEnabled = true
|
||||||
result.allAddresses = false
|
result.allAddresses = false
|
||||||
|
|
||||||
proc `$`*(self: Filter): string =
|
proc `$`*(self: Filter): string =
|
||||||
|
@ -37,10 +39,6 @@ proc includeWatchOnlyToggled*(self: Filter) =
|
||||||
else:
|
else:
|
||||||
self.addresses = self.controller.getWalletAccounts().filter(a => a.walletType != "watch").map(a => a.address)
|
self.addresses = self.controller.getWalletAccounts().filter(a => a.walletType != "watch").map(a => a.address)
|
||||||
|
|
||||||
proc load*(self: Filter) =
|
|
||||||
self.includeWatchOnlyToggled()
|
|
||||||
self.chainIds = self.controller.getEnabledChainIds()
|
|
||||||
|
|
||||||
proc setAddress*(self: Filter, address: string) =
|
proc setAddress*(self: Filter, address: string) =
|
||||||
self.allAddresses = false
|
self.allAddresses = false
|
||||||
self.addresses = @[address]
|
self.addresses = @[address]
|
||||||
|
@ -50,10 +48,15 @@ proc removeAddress*(self: Filter, address: string) =
|
||||||
let accounts = self.controller.getWalletAccounts()
|
let accounts = self.controller.getWalletAccounts()
|
||||||
self.addresses = @[accounts[0].address]
|
self.addresses = @[accounts[0].address]
|
||||||
return
|
return
|
||||||
|
|
||||||
let ind = self.addresses.find(address)
|
let ind = self.addresses.find(address)
|
||||||
if ind > -1:
|
if ind > -1:
|
||||||
self.addresses.delete(ind)
|
self.addresses.delete(ind)
|
||||||
|
|
||||||
proc updateNetworks*(self: Filter) =
|
proc updateNetworks*(self: Filter) =
|
||||||
self.chainIds = self.controller.getEnabledChainIds()
|
self.chainIds = self.controller.getEnabledChainIds()
|
||||||
|
self.allChainsEnabled = (self.chainIds.len == self.controller.getNetworks().len)
|
||||||
|
|
||||||
|
proc load*(self: Filter) =
|
||||||
|
self.includeWatchOnlyToggled()
|
||||||
|
self.updateNetworks()
|
|
@ -169,7 +169,7 @@ method notifyFilterChanged(self: Module) =
|
||||||
self.assetsModule.filterChanged(self.filter.addresses, self.filter.chainIds)
|
self.assetsModule.filterChanged(self.filter.addresses, self.filter.chainIds)
|
||||||
self.accountsModule.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.sendModule.filterChanged(self.filter.addresses, self.filter.chainIds)
|
||||||
self.activityController.globalFilterChanged(self.filter.addresses, self.filter.chainIds)
|
self.activityController.globalFilterChanged(self.filter.addresses, self.filter.chainIds, self.filter.allChainsEnabled)
|
||||||
self.collectiblesController.globalFilterChanged(self.filter.addresses, self.filter.chainIds)
|
self.collectiblesController.globalFilterChanged(self.filter.addresses, self.filter.chainIds)
|
||||||
if self.filter.addresses.len > 0:
|
if self.filter.addresses.len > 0:
|
||||||
self.view.filterChanged(self.filter.addresses[0], includeWatchOnly, self.filter.allAddresses)
|
self.view.filterChanged(self.filter.addresses[0], includeWatchOnly, self.filter.allAddresses)
|
||||||
|
|
Loading…
Reference in New Issue