parent
0f07ea09da
commit
99c113c829
|
@ -128,7 +128,7 @@ method refreshWalletAccounts*(self: Module) =
|
|||
let ownedWalletAccounts = walletAccounts.filter(a => a.walletType != WalletTypeWatch)
|
||||
let ownedWalletAccountAddresses = ownedWalletAccounts.map(a => a.address)
|
||||
let enabledNetworks = self.controller.getEnabledChainIds()
|
||||
self.collectiblesController.globalFilterChanged(ownedWalletAccountAddresses, enabledNetworks)
|
||||
self.collectiblesController.setFilterAddressesAndChains(ownedWalletAccountAddresses, enabledNetworks)
|
||||
|
||||
method load*(self: Module) =
|
||||
self.events.on(SIGNAL_KEYPAIR_SYNCED) do(e: Args):
|
||||
|
|
|
@ -175,7 +175,7 @@ method notifyFilterChanged(self: Module) =
|
|||
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.allAddresses, self.filter.chainIds, self.filter.allChainsEnabled)
|
||||
self.collectiblesController.globalFilterChanged(self.filter.addresses, self.filter.chainIds)
|
||||
self.collectiblesController.setFilterAddressesAndChains(self.filter.addresses, self.filter.chainIds)
|
||||
if self.filter.addresses.len > 0:
|
||||
self.view.filterChanged(self.filter.addresses[0], self.filter.allAddresses)
|
||||
|
||||
|
|
|
@ -356,7 +356,7 @@ method filterChanged*(self: Module, addresses: seq[string], chainIds: seq[int])
|
|||
proc updateCollectiblesFilter*(self: Module) =
|
||||
let addresses = @[self.view.getSenderAddressByIndex(self.senderCurrentAccountIndex)]
|
||||
let chainIds = self.controller.getChainIds()
|
||||
self.collectiblesController.globalFilterChanged(addresses, chainIds)
|
||||
self.collectiblesController.setFilterAddressesAndChains(addresses, chainIds)
|
||||
|
||||
method setSelectedSenderAccountIndex*(self: Module, index: int) =
|
||||
self.senderCurrentAccountIndex = index
|
||||
|
|
|
@ -22,6 +22,7 @@ QtObject:
|
|||
|
||||
addresses: seq[string]
|
||||
chainIds: seq[int]
|
||||
filter: backend_collectibles.CollectibleFilter
|
||||
|
||||
ownershipStatus: Table[string, Table[int, OwnershipStatus]] # Table[address][chainID] -> OwnershipStatus
|
||||
|
||||
|
@ -43,7 +44,6 @@ QtObject:
|
|||
QtProperty[QVariant] model:
|
||||
read = getModelAsVariant
|
||||
|
||||
|
||||
proc checkModelState(self: Controller) =
|
||||
var overallState = OwnershipStateIdle
|
||||
|
||||
|
@ -112,7 +112,7 @@ QtObject:
|
|||
offset = self.model.getCollectiblesCount()
|
||||
self.fetchFromStart = false
|
||||
|
||||
let response = backend_collectibles.filterOwnedCollectiblesAsync(self.requestId, self.chainIds, self.addresses, offset, FETCH_BATCH_COUNT_DEFAULT)
|
||||
let response = backend_collectibles.filterOwnedCollectiblesAsync(self.requestId, self.chainIds, self.addresses, self.filter, offset, FETCH_BATCH_COUNT_DEFAULT)
|
||||
if response.error != nil:
|
||||
self.model.setIsFetching(false)
|
||||
self.model.setIsError(true)
|
||||
|
@ -184,6 +184,7 @@ QtObject:
|
|||
|
||||
result.addresses = @[]
|
||||
result.chainIds = @[]
|
||||
result.filter = backend_collectibles.newCollectibleFilterAllEntries()
|
||||
|
||||
result.setup()
|
||||
|
||||
|
@ -191,7 +192,7 @@ QtObject:
|
|||
|
||||
signalConnect(result.model, "loadMoreItems()", result, "loadMoreItems()")
|
||||
|
||||
proc globalFilterChanged*(self: Controller, addresses: seq[string], chainIds: seq[int]) =
|
||||
proc setFilterAddressesAndChains*(self: Controller, addresses: seq[string], chainIds: seq[int]) =
|
||||
if chainIds == self.chainIds and addresses == self.addresses:
|
||||
return
|
||||
|
||||
|
@ -205,5 +206,13 @@ QtObject:
|
|||
|
||||
self.resetModel()
|
||||
|
||||
proc setFilter*(self: Controller, filter: backend_collectibles.CollectibleFilter) =
|
||||
if filter == self.filter:
|
||||
return
|
||||
|
||||
self.filter = filter
|
||||
|
||||
self.resetModel()
|
||||
|
||||
proc getActivityToken*(self: Controller, id: string): backend_activity.Token =
|
||||
return self.model.getActivityToken(id)
|
|
@ -61,6 +61,17 @@ type
|
|||
CommunityCollectiblesReceivedPayload* = object
|
||||
collectibles*: seq[CommunityCollectibleHeader]
|
||||
|
||||
# see status-go/services/wallet/collectibles/filter.go FilterCommunityType
|
||||
FilterCommunityType* {.pure.} = enum
|
||||
All, OnlyNonCommunity, OnlyCommunity
|
||||
|
||||
# see status-go/services/wallet/collectibles/filter.go Filter
|
||||
# All empty sequences mean include all
|
||||
CollectibleFilter* = object
|
||||
communityIds*: seq[string]
|
||||
communityPrivilegesLevels*: seq[int]
|
||||
filterCommunity*: FilterCommunityType
|
||||
|
||||
# CollectibleOwnershipState
|
||||
proc `$`*(self: OwnershipStatus): string =
|
||||
return fmt"""OwnershipStatus(
|
||||
|
@ -74,6 +85,36 @@ proc fromJson*(t: JsonNode, T: typedesc[OwnershipStatus]): OwnershipStatus {.inl
|
|||
timestamp: t{"timestamp"}.getInt
|
||||
)
|
||||
|
||||
# CollectibleFilter
|
||||
proc newCollectibleFilterAllCommunityIds*(): seq[string] {.inline.} =
|
||||
return @[]
|
||||
|
||||
proc newCollectibleFilterAllCommunityPrivilegesLevels*(): seq[int] {.inline.} =
|
||||
return @[]
|
||||
|
||||
proc newCollectibleFilterAllEntries*(): CollectibleFilter {.inline.} =
|
||||
return CollectibleFilter(
|
||||
communityIds: newCollectibleFilterAllCommunityIds(),
|
||||
communityPrivilegesLevels: newCollectibleFilterAllCommunityPrivilegesLevels(),
|
||||
filterCommunity: FilterCommunityType.All
|
||||
)
|
||||
|
||||
proc `$`*(self: CollectibleFilter): string =
|
||||
return fmt"""CollectibleFilter(
|
||||
communityIds:{self.communityIds},
|
||||
communityPrivilegesLevels:{self.communityPrivilegesLevels},
|
||||
filterCommunity:{self.filterCommunity}
|
||||
"""
|
||||
|
||||
proc `%`*(t: CollectibleFilter): JsonNode {.inline.} =
|
||||
result = newJObject()
|
||||
result["community_ids"] = %(t.communityIds)
|
||||
result["community_privileges_levels"] = %(t.communityPrivilegesLevels)
|
||||
result["filter_community"] = %(t.filterCommunity.int)
|
||||
|
||||
proc `%`*(t: ref CollectibleFilter): JsonNode {.inline.} =
|
||||
return %(t[])
|
||||
|
||||
# Responses
|
||||
proc fromJson*(e: JsonNode, T: typedesc[FilterOwnedCollectiblesResponse]): FilterOwnedCollectiblesResponse {.inline.} =
|
||||
var collectibles: seq[CollectibleHeader]
|
||||
|
@ -146,6 +187,7 @@ rpc(filterOwnedCollectiblesAsync, "wallet"):
|
|||
requestId: int32
|
||||
chainIDs: seq[int]
|
||||
addresses: seq[string]
|
||||
filter: CollectibleFilter
|
||||
offset: int
|
||||
limit: int
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit eb437e9d8dd5bd1ca3b18fa05c4853d6ae8f4956
|
||||
Subproject commit 9f69c3259397821483bad722ab92eb52470185de
|
Loading…
Reference in New Issue