feat(@desktop/wallet): Added missing filter types (#12109)

This commit is contained in:
Cuteivist 2023-09-11 13:43:21 +02:00 committed by GitHub
parent 50ffbb9dce
commit 3548cee149
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 16 deletions

View File

@ -40,6 +40,9 @@ QtObject:
proc delete*(self: ActivityEntry) = proc delete*(self: ActivityEntry) =
self.QObject.delete self.QObject.delete
proc isInTransactionType(self: ActivityEntry): bool =
return self.metadata.activityType == backend.ActivityType.Receive or self.metadata.activityType == backend.ActivityType.Mint
proc newMultiTransactionActivityEntry*(metadata: backend.ActivityEntry, extradata: ExtraData, valueConvertor: AmountToCurrencyConvertor): ActivityEntry = proc newMultiTransactionActivityEntry*(metadata: backend.ActivityEntry, extradata: ExtraData, valueConvertor: AmountToCurrencyConvertor): ActivityEntry =
new(result, delete) new(result, delete)
result.valueConvertor = valueConvertor result.valueConvertor = valueConvertor
@ -47,8 +50,8 @@ QtObject:
result.extradata = extradata result.extradata = extradata
result.noAmount = newCurrencyAmount() result.noAmount = newCurrencyAmount()
result.amountCurrency = valueConvertor( result.amountCurrency = valueConvertor(
if metadata.activityType == backend.ActivityType.Receive: metadata.amountIn else: metadata.amountOut, if result.isInTransactionType(): metadata.amountIn else: metadata.amountOut,
if metadata.activityType == backend.ActivityType.Receive: metadata.symbolIn.get("") else: metadata.symbolOut.get(""), if result.isInTransactionType(): metadata.symbolIn.get("") else: metadata.symbolOut.get(""),
) )
result.setup() result.setup()
@ -59,8 +62,8 @@ QtObject:
result.extradata = extradata result.extradata = extradata
result.amountCurrency = valueConvertor( result.amountCurrency = valueConvertor(
if metadata.activityType == backend.ActivityType.Receive: metadata.amountIn else: metadata.amountOut, if result.isInTransactionType(): metadata.amountIn else: metadata.amountOut,
if metadata.activityType == backend.ActivityType.Receive: metadata.symbolIn.get("") else: metadata.symbolOut.get(""), if result.isInTransactionType(): metadata.symbolIn.get("") else: metadata.symbolOut.get(""),
) )
result.noAmount = newCurrencyAmount() result.noAmount = newCurrencyAmount()
@ -83,9 +86,6 @@ QtObject:
metadata:{$self.metadata}, metadata:{$self.metadata},
)""" )"""
proc isInTransactionType(self: ActivityEntry): bool =
return self.metadata.activityType == backend.ActivityType.Receive or self.metadata.activityType == backend.ActivityType.Mint
# TODO: is this the right way to pass transaction identity? Why not use the instance? # TODO: is this the right way to pass transaction identity? Why not use the instance?
proc getId*(self: ActivityEntry): string {.slot.} = proc getId*(self: ActivityEntry): string {.slot.} =
if self.isMultiTransaction(): if self.isMultiTransaction():

View File

@ -76,12 +76,14 @@ Column {
return qsTr("Send") return qsTr("Send")
case Constants.TransactionType.Receive: case Constants.TransactionType.Receive:
return qsTr("Receive") return qsTr("Receive")
case Constants.TransactionType.Buy:
return qsTr("Buy")
case Constants.TransactionType.Swap: case Constants.TransactionType.Swap:
return qsTr("Swap") return qsTr("Swap")
case Constants.TransactionType.Bridge: case Constants.TransactionType.Bridge:
return qsTr("Bridge") return qsTr("Bridge")
case Constants.TransactionType.ContractDeployment:
return qsTr("Contract Deployment")
case Constants.TransactionType.Mint:
return qsTr("Mint")
default: default:
console.warn("Unhandled type :: ",activityFilterStore.typeFilters[index]) console.warn("Unhandled type :: ",activityFilterStore.typeFilters[index])
return "" return ""
@ -91,12 +93,14 @@ Column {
return "send" return "send"
case Constants.TransactionType.Receive: case Constants.TransactionType.Receive:
return "receive" return "receive"
case Constants.TransactionType.Buy:
return "token"
case Constants.TransactionType.Swap: case Constants.TransactionType.Swap:
return "swap" return "swap"
case Constants.TransactionType.Bridge: case Constants.TransactionType.Bridge:
return "bridge" return "bridge"
case Constants.TransactionType.ContractDeployment:
return "contract_deploy"
case Constants.TransactionType.Mint:
return "token"
default: default:
console.warn("Unhandled type :: ",activityFilterStore.typeFilters[index]) console.warn("Unhandled type :: ",activityFilterStore.typeFilters[index])
return "" return ""
@ -128,7 +132,7 @@ Column {
case Constants.TransactionStatus.Pending: case Constants.TransactionStatus.Pending:
return Style.svg("transaction/pending") return Style.svg("transaction/pending")
case Constants.TransactionStatus.Complete: case Constants.TransactionStatus.Complete:
return Style.svg("transaction/verified") return Style.svg("transaction/confirmed")
case Constants.TransactionStatus.Finished: case Constants.TransactionStatus.Finished:
return Style.svg("transaction/finished") return Style.svg("transaction/finished")
default: default:

View File

@ -70,6 +70,7 @@ StatusMenu {
} }
ActivityTypeFilterSubMenu { ActivityTypeFilterSubMenu {
id: typeMenu id: typeMenu
implicitWidth: 230
onBack: root.open() onBack: root.open()
typeFilters: root.typeFilters typeFilters: root.typeFilters
onActionTriggered: updateTypeFilter(type, allFiltersCount) onActionTriggered: updateTypeFilter(type, allFiltersCount)

View File

@ -57,7 +57,7 @@ StatusMenu {
ActivityTypeCheckBox { ActivityTypeCheckBox {
id: buyCheckbox id: buyCheckbox
title: qsTr("Complete") title: qsTr("Complete")
assetSettings.name: Style.svg("transaction/verified") assetSettings.name: Style.svg("transaction/confirmed")
assetSettings.color: "transparent" assetSettings.color: "transparent"
buttonGroup: typeButtonGroup buttonGroup: typeButtonGroup
allChecked: root.allChecked allChecked: root.allChecked

View File

@ -53,12 +53,23 @@ StatusMenu {
} }
ActivityTypeCheckBox { ActivityTypeCheckBox {
id: buyCheckbox id: contractDeploymentCheckbox
title: qsTr("Buy") title: qsTr("Contract Deployment")
assetSettings.name: "contract_deploy"
buttonGroup: typeButtonGroup
allChecked: root.allChecked
type: Constants.TransactionType.ContractDeployment
checked: root.allChecked || typeFilters.includes(type)
onActionTriggered: root.actionTriggered(type)
}
ActivityTypeCheckBox {
id: mintCheckbox
title: qsTr("Mint")
assetSettings.name: "token" assetSettings.name: "token"
buttonGroup: typeButtonGroup buttonGroup: typeButtonGroup
allChecked: root.allChecked allChecked: root.allChecked
type: Constants.TransactionType.Buy type: Constants.TransactionType.Mint
checked: root.allChecked || typeFilters.includes(type) checked: root.allChecked || typeFilters.includes(type)
onActionTriggered: root.actionTriggered(type) onActionTriggered: root.actionTriggered(type)
} }