feat(@esktop/wallet): Implemented filter by similar option (#12232)
This commit is contained in:
parent
58ccb01b76
commit
5bf905b91d
|
@ -340,4 +340,22 @@ QtObject:
|
|||
if tokenId > 0:
|
||||
result.tokenId = some(backend_activity.TokenId("0x" & stint.toHex(tokenId)))
|
||||
return result
|
||||
|
||||
# Fallback, use data from id
|
||||
var parts = id.split("+")
|
||||
if len(parts) == 3:
|
||||
result.chainId = backend_activity.ChainId(parseInt(parts[0]))
|
||||
result.address = some(eth.fromHex(eth.Address, parts[1]))
|
||||
var tokenIdInt = u256(parseInt(parts[2]))
|
||||
result.tokenId = some(backend_activity.TokenId("0x" & stint.toHex(tokenIdInt)))
|
||||
|
||||
return result
|
||||
|
||||
proc getUidForData*(self: Model, tokenId: string, tokenAddress: string, chainId: int): string {.slot.} =
|
||||
for item in self.items:
|
||||
if(cmpIgnoreCase(item.getTokenId().toString(), tokenId) == 0 and cmpIgnoreCase(item.getContractAddress(), tokenAddress) == 0):
|
||||
return item.getId()
|
||||
# Fallback, create uid from data, because it still might not be fetched
|
||||
if chainId > 0 and len(tokenAddress) > 0 and len(tokenId) > 0:
|
||||
return $chainId & "+" & tokenAddress & "+" & tokenId
|
||||
return ""
|
|
@ -163,8 +163,17 @@ Column {
|
|||
delegate: ActivityFilterTagItem {
|
||||
id: collectibleTag
|
||||
property string uid: modelData
|
||||
readonly property bool isValid: tagPrimaryLabel.text.length > 0
|
||||
tagPrimaryLabel.text: activityFilterStore.collectiblesList.getName(uid)
|
||||
readonly property string name: activityFilterStore.collectiblesList.getName(uid)
|
||||
readonly property bool isValid: name.length > 0
|
||||
tagPrimaryLabel.text: {
|
||||
if (!!name)
|
||||
return name
|
||||
// Fallback, get tokenId from uid
|
||||
const data = uid.split("+")
|
||||
if (data.length === 3)
|
||||
return "#" + data[2]
|
||||
return ""
|
||||
}
|
||||
iconAsset.icon: activityFilterStore.collectiblesList.getImageUrl(uid)
|
||||
iconAsset.color: "transparent"
|
||||
onClosed: activityFilterStore.toggleCollectibles(uid)
|
||||
|
@ -174,7 +183,7 @@ Column {
|
|||
target: activityFilterStore.collectiblesList
|
||||
enabled: !collectibleTag.isValid
|
||||
function onIsFetchingChanged() {
|
||||
if (activityFilterStore.collectiblesList.isFetching)
|
||||
if (activityFilterStore.collectiblesList.isFetching || !activityFilterStore.collectiblesList.hasMore)
|
||||
return
|
||||
collectibleTag.uid = ""
|
||||
collectibleTag.uid = modelData
|
||||
|
|
|
@ -10,6 +10,7 @@ QtObject {
|
|||
|
||||
property var transactionsList: walletSection.activityController.model
|
||||
|
||||
property bool autoUpdateFilter: true
|
||||
property var activityController: walletSection.activityController
|
||||
property bool filtersSet: selectedTime !== Constants.TransactionTimePeriod.All ||
|
||||
typeFilters.length !== 0 ||
|
||||
|
@ -153,16 +154,18 @@ QtObject {
|
|||
? activityController.noLimitTimestamp
|
||||
: toTimestamp/1000
|
||||
activityController.setFilterTime(startTimestamp, endTimestamp)
|
||||
if (autoUpdateFilter)
|
||||
activityController.updateFilter()
|
||||
}
|
||||
|
||||
// Type Filters
|
||||
property var typeFilters: []
|
||||
function toggleType(type, allFiltersCount) {
|
||||
function toggleType(type, allFiltersCount = 0) {
|
||||
// update filters
|
||||
typeFilters = d.toggleFilterState(typeFilters, type, allFiltersCount)
|
||||
// Set backend values
|
||||
activityController.setFilterType(JSON.stringify(typeFilters))
|
||||
if (autoUpdateFilter)
|
||||
activityController.updateFilter()
|
||||
}
|
||||
|
||||
|
@ -173,6 +176,7 @@ QtObject {
|
|||
statusFilters = d.toggleFilterState(statusFilters, status, allFiltersCount)
|
||||
// Set backend values
|
||||
activityController.setFilterStatus(JSON.stringify(statusFilters))
|
||||
if (autoUpdateFilter)
|
||||
activityController.updateFilter()
|
||||
}
|
||||
|
||||
|
@ -184,17 +188,19 @@ QtObject {
|
|||
tokensFilter = d.toggleFilterState(tokensFilter, symbol, tokensList.count)
|
||||
// Set backend values
|
||||
activityController.setFilterAssets(JSON.stringify(tokensFilter), false)
|
||||
if (autoUpdateFilter)
|
||||
activityController.updateFilter()
|
||||
}
|
||||
|
||||
// Collectibles Filters
|
||||
// To-do: Get list of collectibles with activity from backend
|
||||
property var collectiblesList: walletSection.collectiblesController.model
|
||||
property var collectiblesFilter: []
|
||||
function toggleCollectibles(uid) {
|
||||
// update filters
|
||||
collectiblesFilter = d.toggleFilterState(collectiblesFilter, uid, collectiblesList.count)
|
||||
// set backend values
|
||||
activityController.setFilterCollectibles(JSON.stringify(collectiblesFilter))
|
||||
if (autoUpdateFilter)
|
||||
activityController.updateFilter()
|
||||
}
|
||||
|
||||
|
@ -208,6 +214,7 @@ QtObject {
|
|||
// update filters
|
||||
recentsFilters = d.toggleFilterState(recentsFilters, address, recentsList.count)
|
||||
activityController.setFilterToAddresses(JSON.stringify(recentsFilters.concat(savedAddressFilters)))
|
||||
if (autoUpdateFilter)
|
||||
activityController.updateFilter()
|
||||
}
|
||||
|
||||
|
@ -236,6 +243,7 @@ QtObject {
|
|||
savedAddressFilters = d.toggleFilterState(savedAddressFilters, address, savedAddressList.count)
|
||||
// Set backend values
|
||||
activityController.setFilterToAddresses(JSON.stringify(recentsFilters.concat(savedAddressFilters)))
|
||||
if (autoUpdateFilter)
|
||||
activityController.updateFilter()
|
||||
}
|
||||
|
||||
|
@ -251,6 +259,7 @@ QtObject {
|
|||
activityController.setFilterToAddresses(JSON.stringify(recentsFilters.concat(savedAddressFilters)))
|
||||
activityController.setFilterCollectibles(JSON.stringify(collectiblesFilter))
|
||||
|
||||
if (autoUpdateFilter)
|
||||
activityController.updateFilter()
|
||||
}
|
||||
|
||||
|
|
|
@ -297,12 +297,12 @@ ColumnLayout {
|
|||
property var transaction
|
||||
property var transactionDelegate
|
||||
|
||||
function openMenu(delegate, mouse) {
|
||||
if (!delegate || !delegate.modelData)
|
||||
function openMenu(delegate, mouse, data) {
|
||||
if (!delegate || !data)
|
||||
return
|
||||
|
||||
delegateMenu.transactionDelegate = delegate
|
||||
delegateMenu.transaction = delegate.modelData
|
||||
delegateMenu.transaction = data
|
||||
repeatTransactionAction.enabled = !overview.isWatchOnlyAccount && delegate.modelData.txType === TransactionDelegate.Send
|
||||
popup(delegate, mouse.x, mouse.y)
|
||||
}
|
||||
|
@ -338,11 +338,40 @@ ColumnLayout {
|
|||
}
|
||||
StatusAction {
|
||||
id: filterAction
|
||||
enabled: false
|
||||
text: qsTr("Filter by similar")
|
||||
icon.name: "filter"
|
||||
onTriggered: {
|
||||
// TODO apply filter
|
||||
const store = WalletStores.RootStore.currentActivityFiltersStore
|
||||
const tx = delegateMenu.transaction
|
||||
|
||||
store.autoUpdateFilter = false
|
||||
store.resetAllFilters()
|
||||
|
||||
const currentAddress = overview.mixedcaseAddress.toUpperCase()
|
||||
|
||||
store.toggleType(tx.txType)
|
||||
// Contract deployment has always ETH symbol. Symbol doesn't affect this type
|
||||
if (tx.txType !== Constants.TransactionType.ContractDeployment) {
|
||||
const symbol = tx.symbol
|
||||
if (!!symbol)
|
||||
store.toggleToken(symbol)
|
||||
const inSymbol = tx.inSymbol
|
||||
if (!!inSymbol && inSymbol !== symbol)
|
||||
store.toggleToken(inSymbol)
|
||||
}
|
||||
if (showAllAccounts || tx.txType !== Constants.TransactionType.Bridge) {
|
||||
const recipient = tx.recipient.toUpperCase()
|
||||
if (!!recipient && recipient !== currentAddress && !/0X0+$/.test(recipient))
|
||||
store.toggleRecents(recipient)
|
||||
}
|
||||
if (tx.isNFT) {
|
||||
const uid = store.collectiblesList.getUidForData(tx.tokenID, tx.tokenAddress, tx.chainId)
|
||||
if (!!uid)
|
||||
store.toggleCollectibles(uid)
|
||||
}
|
||||
|
||||
store.autoUpdateFilter = true
|
||||
store.applyAllFilters()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue