fix(@desktop/wallet): Activity UI filtering improvements

1. Handling case where filters result in no results
2. Fixed period filter
3. Used recipient model from go side
This commit is contained in:
Khushboo Mehta 2023-06-20 13:14:52 +02:00 committed by Khushboo-dev-cpp
parent ae9a52397c
commit 9be598ee32
7 changed files with 331 additions and 235 deletions

View File

@ -370,8 +370,9 @@ QtObject:
error "error fetching recipients: ", response.error
return
let result = json.to(response.result, backend_activity.GetAllRecipientsResponse)
self.recipientsModel.addAddresses(result.addresses, 0, result.hasMore)
if response.result["addresses"] != newJNull():
let result = json.to(response.result, backend_activity.GetAllRecipientsResponse)
self.recipientsModel.addAddresses(deduplicate(result.addresses), 0, result.hasMore)
proc loadMoreRecipients(self: Controller) {.slot.} =
let response = backend_activity.getAllRecipients(self.recipientsModel.getCount(), FETCH_RECIPIENTS_BATCH_COUNT_DEFAULT)
@ -379,8 +380,9 @@ QtObject:
error "error fetching more recipient entries: ", response.error
return
let result = json.to(response.result, backend_activity.GetAllRecipientsResponse)
self.recipientsModel.addAddresses(result.addresses, self.recipientsModel.getCount(), result.hasMore)
if response.result["addresses"] != newJNull():
let result = json.to(response.result, backend_activity.GetAllRecipientsResponse)
self.recipientsModel.addAddresses(deduplicate(result.addresses), self.recipientsModel.getCount(), result.hasMore)
proc getStartTimestamp*(self: Controller): int {.slot.} =
return if self.startTimestamp > 0:

View File

@ -7,171 +7,200 @@ import StatusQ.Controls 0.1
import utils 1.0
import shared.panels 1.0
import "../controls"
import "../popups"
Flow {
Column {
id: root
property var activityFilterStore
property var store
property bool isLoading: false
spacing: 8
spacing: 12
Component.onCompleted: {
activityFilterStore.updateFilterBase()
}
StatusRoundButton {
id: filterButton
width: 32
height: 32
icon.name: "filter"
border.width: 1
border.color: Theme.palette.directColor8
type: StatusRoundButton.Type.Tertiary
onClicked: activityFilterMenu.popup(x, y + height + 4)
}
Flow {
width: parent.width
ActivityFilterTagItem {
tagPrimaryLabel.text: LocaleUtils.formatDate(activityFilterStore.fromTimestamp)
tagSecondaryLabel.text: {
switch(activityFilterMenu.selectedTime) {
case Constants.TransactionTimePeriod.Today:
case Constants.TransactionTimePeriod.Yesterday:
return ""
default:
return LocaleUtils.formatDate(activityFilterStore.toTimestamp)
spacing: 8
StatusRoundButton {
id: filterButton
width: 32
height: 32
icon.name: "filter"
border.width: 1
border.color: Theme.palette.directColor8
type: StatusRoundButton.Type.Tertiary
icon.color: Theme.palette.primaryColor1
onClicked: activityFilterMenu.popup(x, y + height + 4)
}
ActivityFilterTagItem {
tagPrimaryLabel.text: LocaleUtils.formatDate(activityFilterStore.fromTimestamp)
tagSecondaryLabel.text: {
switch(activityFilterMenu.selectedTime) {
case Constants.TransactionTimePeriod.Today:
case Constants.TransactionTimePeriod.Yesterday:
return ""
default:
return LocaleUtils.formatDate(activityFilterStore.toTimestamp)
}
}
middleLabel.text: {
switch(activityFilterMenu.selectedTime) {
case Constants.TransactionTimePeriod.Today:
case Constants.TransactionTimePeriod.Yesterday:
return ""
default:
return qsTr("to")
}
}
iconAsset.icon: "history"
visible: activityFilterMenu.selectedTime !== Constants.TransactionTimePeriod.All
onClosed: activityFilterStore.setSelectedTimestamp(Constants.TransactionTimePeriod.All)
}
Repeater {
model: activityFilterMenu.allTypesChecked ? 0: activityFilterStore.typeFilters
delegate: ActivityFilterTagItem {
property int type: activityFilterStore.typeFilters[index]
tagPrimaryLabel.text: switch(activityFilterStore.typeFilters[index]) {
case Constants.TransactionType.Send:
return qsTr("Send")
case Constants.TransactionType.Receive:
return qsTr("Receive")
case Constants.TransactionType.Buy:
return qsTr("Buy")
case Constants.TransactionType.Swap:
return qsTr("Swap")
case Constants.TransactionType.Bridge:
return qsTr("Bridge")
default:
console.warn("Unhandled type :: ",activityFilterStore.typeFilters[index])
return ""
}
iconAsset.icon: switch(activityFilterStore.typeFilters[index]) {
case Constants.TransactionType.Send:
return "send"
case Constants.TransactionType.Receive:
return "receive"
case Constants.TransactionType.Buy:
return "token"
case Constants.TransactionType.Swap:
return "swap"
case Constants.TransactionType.Bridge:
return "bridge"
default:
console.warn("Unhandled type :: ",activityFilterStore.typeFilters[index])
return ""
}
onClosed: activityFilterStore.toggleType(type)
}
}
middleLabel.text: {
switch(activityFilterMenu.selectedTime) {
case Constants.TransactionTimePeriod.Today:
case Constants.TransactionTimePeriod.Yesterday:
return ""
default:
return qsTr("to")
Repeater {
model: activityFilterMenu.allStatusChecked ? 0 : activityFilterStore.statusFilters
delegate: ActivityFilterTagItem {
property int status: activityFilterStore.statusFilters[index]
tagPrimaryLabel.text: switch(activityFilterStore.statusFilters[index]) {
case Constants.TransactionStatus.Failed:
return qsTr("Failed")
case Constants.TransactionStatus.Pending:
return qsTr("Pending")
case Constants.TransactionStatus.Complete:
return qsTr("Complete")
case Constants.TransactionStatus.Finished:
return qsTr("Finalised")
default:
console.warn("Unhandled status :: ",activityFilterStore.statusFilters[index])
return ""
}
iconAsset.icon: switch(activityFilterStore.statusFilters[index]) {
case Constants.TransactionStatus.Failed:
return Style.svg("transaction/failed")
case Constants.TransactionStatus.Pending:
return Style.svg("transaction/pending")
case Constants.TransactionStatus.Complete:
return Style.svg("transaction/verified")
case Constants.TransactionStatus.Finished:
return Style.svg("transaction/finished")
default:
console.warn("Unhandled status :: ",activityFilterStore.statusFilters[index])
return ""
}
iconAsset.color: "transparent"
onClosed: activityFilterStore.toggleStatus(status, activityFilterMenu.allStatusChecked)
}
}
iconAsset.icon: "history"
visible: activityFilterMenu.selectedTime !== Constants.TransactionTimePeriod.All
onClosed: activityFilterStore.setSelectedTimestamp(Constants.TransactionTimePeriod.All)
}
Repeater {
model: activityFilterMenu.allTypesChecked ? 0: activityFilterStore.typeFilters
delegate: ActivityFilterTagItem {
property int type: activityFilterStore.typeFilters[index]
tagPrimaryLabel.text: switch(activityFilterStore.typeFilters[index]) {
case Constants.TransactionType.Send:
return qsTr("Send")
case Constants.TransactionType.Receive:
return qsTr("Receive")
case Constants.TransactionType.Buy:
return qsTr("Buy")
case Constants.TransactionType.Swap:
return qsTr("Swap")
case Constants.TransactionType.Bridge:
return qsTr("Bridge")
default:
console.warn("Unhandled type :: ",activityFilterStore.typeFilters[index])
return ""
}
iconAsset.icon: switch(activityFilterStore.typeFilters[index]) {
case Constants.TransactionType.Send:
return "send"
case Constants.TransactionType.Receive:
return "receive"
case Constants.TransactionType.Buy:
return "token"
case Constants.TransactionType.Swap:
return "swap"
case Constants.TransactionType.Bridge:
return "bridge"
default:
console.warn("Unhandled type :: ",activityFilterStore.typeFilters[index])
return ""
}
onClosed: activityFilterStore.toggleType(type)
Repeater {
model: activityFilterStore.tokensList
delegate: ActivityFilterTagItem {
tagPrimaryLabel.text: symbol
iconAsset.icon: Constants.tokenIcon(symbol)
iconAsset.color: "transparent"
visible: !activityFilterMenu.allTokensChecked && activityFilterStore.tokensFilter.includes(symbol)
onClosed: activityFilterStore.toggleToken(symbol)
}
}
Repeater {
model: activityFilterStore.collectiblesList
delegate: ActivityFilterTagItem {
tagPrimaryLabel.text: model.name
iconAsset.icon: model.imageUrl
iconAsset.color: "transparent"
visible: !activityFilterMenu.allCollectiblesChecked && activityFilterStore.collectiblesFilter.includes(model.id)
onClosed: activityFilterStore.toggleCollectibles(model.id)
}
}
Repeater {
model: activityFilterStore.recentsList
delegate: ActivityFilterTagItem {
tagPrimaryLabel.text: root.store.getNameForAddress(model.address) || StatusQUtils.Utils.elideText(model.address,6,4)
visible: !activityFilterMenu.allRecentsChecked && activityFilterMenu.recentsFilters.includes(model.address)
onClosed: activityFilterStore.toggleRecents(model.address)
}
}
Repeater {
model: activityFilterStore.savedAddressList
delegate: ActivityFilterTagItem {
tagPrimaryLabel.text: ens.length > 0 ? ens : chainShortNames + StatusQUtils.Utils.elideText(address,6,4)
visible: !activityFilterMenu.allSavedAddressesChecked && activityFilterMenu.savedAddressFilters.includes(address)
onClosed: activityFilterStore.toggleSavedAddress(address)
}
}
}
Repeater {
model: activityFilterMenu.allStatusChecked ? 0 : activityFilterStore.statusFilters
delegate: ActivityFilterTagItem {
property int status: activityFilterStore.statusFilters[index]
tagPrimaryLabel.text: switch(activityFilterStore.statusFilters[index]) {
case Constants.TransactionStatus.Failed:
return qsTr("Failed")
case Constants.TransactionStatus.Pending:
return qsTr("Pending")
case Constants.TransactionStatus.Complete:
return qsTr("Complete")
case Constants.TransactionStatus.Finished:
return qsTr("Finalised")
default:
console.warn("Unhandled status :: ",activityFilterStore.statusFilters[index])
return ""
}
iconAsset.icon: switch(activityFilterStore.statusFilters[index]) {
case Constants.TransactionStatus.Failed:
return Style.svg("transaction/failed")
case Constants.TransactionStatus.Pending:
return Style.svg("transaction/pending")
case Constants.TransactionStatus.Complete:
return Style.svg("transaction/verified")
case Constants.TransactionStatus.Finished:
return Style.svg("transaction/finished")
default:
console.warn("Unhandled status :: ",activityFilterStore.statusFilters[index])
return ""
}
iconAsset.color: "transparent"
onClosed: activityFilterStore.toggleStatus(status, activityFilterMenu.allStatusChecked)
}
Separator {
visible: noResultsAfterFilter.visible
}
Repeater {
model: activityFilterStore.tokensList
delegate: ActivityFilterTagItem {
tagPrimaryLabel.text: symbol
iconAsset.icon: Constants.tokenIcon(symbol)
iconAsset.color: "transparent"
visible: !activityFilterMenu.allTokensChecked && activityFilterStore.tokensFilter.includes(symbol)
onClosed: activityFilterStore.toggleToken(symbol)
}
StatusBaseText {
id: noResultsAfterFilter
anchors.horizontalCenter: parent.horizontalCenter
anchors.topMargin: 16
visible: !root.isLoading && activityFilterStore.transactionsList.count === 0 && activityFilterStore.filtersSet
text: qsTr("No activity items for the current filter")
font.pixelSize: Style.current.primaryTextFontSize
color: Theme.palette.baseColor1
}
Repeater {
model: activityFilterStore.collectiblesList
delegate: ActivityFilterTagItem {
tagPrimaryLabel.text: model.name
iconAsset.icon: model.imageUrl
iconAsset.color: "transparent"
visible: !activityFilterMenu.allCollectiblesChecked && activityFilterStore.collectiblesFilter.includes(model.id)
onClosed: activityFilterStore.toggleCollectibles(model.id)
}
}
Repeater {
model: activityFilterStore.recentsList
delegate: ActivityFilterTagItem {
property int transactionType: to.toLowerCase() === root.store.overview.mixedcaseAddress.toLowerCase() ? Constants.TransactionType.Receive : Constants.TransactionType.Send
tagPrimaryLabel.text: transactionType === Constants.TransactionType.Receive ?
root.store.getNameForAddress(from) || StatusQUtils.Utils.elideText(from,6,4) :
root.store.getNameForAddress(to) || StatusQUtils.Utils.elideText(to,6,4)
visible: !activityFilterMenu.allRecentsChecked && activityFilterMenu.recentsFilters.includes(transactionType === Constants.TransactionType.Receive ? from : to)
onClosed: activityFilterStore.toggleRecents(transactionType === Constants.TransactionType.Receive ? from : to)
}
}
Repeater {
model: activityFilterStore.savedAddressList
delegate: ActivityFilterTagItem {
tagPrimaryLabel.text: ens.length > 0 ? ens : chainShortNames + StatusQUtils.Utils.elideText(address,6,4)
visible: !activityFilterMenu.allSavedAddressesChecked && activityFilterMenu.savedAddressFilters.includes(address)
onClosed: activityFilterStore.toggleSavedAddress(address)
}
StatusButton {
anchors.horizontalCenter: parent.horizontalCenter
visible: noResultsAfterFilter.visible
text: qsTr("Clear all filters")
size: StatusBaseButton.Size.Small
onClicked: activityFilterStore.resetAllFilters()
}
ActivityFilterMenu {
@ -207,6 +236,7 @@ Flow {
savedAddressFilters: activityFilterStore.savedAddressFilters
onUpdateSavedAddressFilter: activityFilterStore.toggleSavedAddress(address)
onUpdateRecentsFilter: activityFilterStore.toggleRecents(address)
onUpdateRecipientsModel: activityFilterStore.updateRecipientsModel()
}
StatusDateRangePicker {

View File

@ -41,6 +41,7 @@ StatusMenu {
property var recentsFilters
readonly property bool allRecentsChecked: counterPartyMenu.allRecentsChecked
signal updateRecentsFilter(string address)
signal updateRecipientsModel()
// Collectibles filter
property var savedAddressList
@ -103,6 +104,7 @@ StatusMenu {
savedAddressFilters: root.savedAddressFilters
onSavedAddressToggled: root.updateSavedAddressFilter(address)
onRecentsToggled: root.updateRecentsFilter(address)
onUpdateRecipientsModel: root.updateRecipientsModel()
closePolicy: root.closePolicy
}
}

View File

@ -33,9 +33,12 @@ StatusMenu {
signal back()
signal savedAddressToggled(string address)
signal recentsToggled(string address)
signal updateRecipientsModel()
implicitWidth: 289
Component.onCompleted: root.updateRecipientsModel()
MenuBackButton {
id: backButton
width: parent.width
@ -74,28 +77,25 @@ StatusMenu {
id: recentsButtonGroup
exclusive: false
}
Repeater {
StatusBaseText {
anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("No Recents")
visible: root.recentsList.count === 0
}
StatusListView {
width: parent.width
height: root.height - tabBar.height - 12
model: root.recentsList
delegate: ActivityTypeCheckBox {
readonly property int transactionType: model.activityEntry.recipient.toLowerCase() === store.overview.mixedcaseAddress.toLowerCase() ? Constants.TransactionType.Receive : Constants.TransactionType.Send
readonly property string fromName: store.getNameForAddress(model.activityEntry.sender)
readonly property string toName: store.getNameForAddress(model.activityEntry.recipient)
width: parent.width
readonly property string name: store.getNameForAddress(model.address)
width: ListView.view.width
height: 44
title: transactionType === Constants.TransactionType.Receive ?
fromName || StatusQUtils.Utils.elideText(model.activityEntry.sender,6,4) :
toName || StatusQUtils.Utils.elideText(model.activityEntry.recipient,6,4)
subTitle: {
if (transactionType === Constants.TransactionType.Receive) {
return fromName ? StatusQUtils.Utils.elideText(model.activityEntry.sender,6,4) : ""
} else {
return toName ? StatusQUtils.Utils.elideText(model.activityEntry.recipient,6,4): ""
}
}
title: name || StatusQUtils.Utils.elideText(model.address,6,4)
subTitle: name ? StatusQUtils.Utils.elideText(model.address,6,4): ""
statusListItemSubTitle.elide: Text.ElideMiddle
statusListItemSubTitle.wrapMode: Text.NoWrap
assetSettings.name: (transactionType === Constants.TransactionType.Receive ? fromName : toName) || "address"
assetSettings.isLetterIdenticon: transactionType === Constants.TransactionType.Receive ? !!fromName : !!toName
assetSettings.name: name || "address"
assetSettings.isLetterIdenticon: !!name
assetSettings.bgHeight: 32
assetSettings.bgWidth: 32
assetSettings.bgRadius: assetSettings.bgHeight/2
@ -103,8 +103,8 @@ StatusMenu {
assetSettings.height: 16
buttonGroup: recentsButtonGroup
allChecked: root.allRecentsChecked
checked: root.allRecentsChecked ? true : root.recentsFilters.includes(transactionType === Constants.TransactionType.Receive ? model.activityEntry.sender: model.activityEntry.recipient)
onActionTriggered: root.recentsToggled(transactionType === Constants.TransactionType.Receive ? model.activityEntry.sender: model.activityEntry.recipient)
checked: root.allRecentsChecked ? true : root.recentsFilters.includes(model.address)
onActionTriggered: root.recentsToggled(model.address)
}
}
}
@ -117,10 +117,17 @@ StatusMenu {
id: savedButtonGroup
exclusive: false
}
Repeater {
StatusBaseText {
anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("No Saved Address")
visible: root.savedAddressList.count === 0
}
StatusListView {
width: parent.width
height: root.height - tabBar.height - 12
model: root.savedAddressList
delegate: ActivityTypeCheckBox {
width: parent.width
width: ListView.view.width
height: 44
title: model.name ?? ""
subTitle: {

View File

@ -76,6 +76,12 @@ StatusMenu {
exclusive: false
}
StatusBaseText {
anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("No Assets")
visible: root.tokensList.count === 0
}
SearchBox {
id: tokensSearchBox
anchors.horizontalCenter: parent.horizontalCenter
@ -84,32 +90,31 @@ StatusMenu {
placeholderText: qsTr("Search asset name")
}
ColumnLayout {
StatusListView {
width: parent.width
height: root.height - tabBar.height - tokensSearchBox.height - 12
spacing: 0
Repeater {
model: SortFilterProxyModel {
sourceModel: root.tokensList
filters: ExpressionFilter {
enabled: root.tokensList.count > 0
expression: {
var tokenSymbolByAddress = root.searchTokenSymbolByAddressFn(tokensSearchBox.text)
return symbol.startsWith(tokensSearchBox.text.toUpperCase()) || name.toUpperCase().startsWith(tokensSearchBox.text.toUpperCase()) || (tokenSymbolByAddress!=="" && symbol.startsWith(tokenSymbolByAddress))
}
model: SortFilterProxyModel {
sourceModel: root.tokensList
filters: ExpressionFilter {
enabled: root.tokensList.count > 0
expression: {
var tokenSymbolByAddress = root.searchTokenSymbolByAddressFn(tokensSearchBox.text)
return symbol.startsWith(tokensSearchBox.text.toUpperCase()) || name.toUpperCase().startsWith(tokensSearchBox.text.toUpperCase()) || (tokenSymbolByAddress!=="" && symbol.startsWith(tokenSymbolByAddress))
}
}
delegate: ActivityTypeCheckBox {
Layout.fillWidth: true
Layout.preferredHeight: 44
title: model.name
titleAsideText: model.symbol
assetSettings.name: model.symbol ? Constants.tokenIcon(symbol) : ""
assetSettings.isImage: true
buttonGroup: tokenButtonGroup
allChecked: root.allTokensChecked
checked: root.allTokensChecked || root.tokensFilter.includes(model.symbol)
onActionTriggered: root.tokenToggled(model.symbol)
}
}
delegate: ActivityTypeCheckBox {
width: ListView.view.width
height: 44
title: model.name
titleAsideText: model.symbol
assetSettings.name: model.symbol ? Constants.tokenIcon(symbol) : ""
assetSettings.isImage: true
buttonGroup: tokenButtonGroup
allChecked: root.allTokensChecked
checked: root.allTokensChecked || root.tokensFilter.includes(model.symbol)
onActionTriggered: root.tokenToggled(model.symbol)
}
}
}
@ -123,6 +128,12 @@ StatusMenu {
exclusive: false
}
StatusBaseText {
anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("No Collectibles")
visible: root.collectiblesList.count === 0
}
SearchBox {
id: collectiblesSearchBox
anchors.horizontalCenter: parent.horizontalCenter
@ -131,35 +142,34 @@ StatusMenu {
placeholderText: qsTr("Search collectible name")
}
ColumnLayout {
StatusListView {
width: parent.width
height: root.height - tabBar.height - tokensSearchBox.height - 12
spacing: 0
Repeater {
model: SortFilterProxyModel {
sourceModel: root.collectiblesList
filters: ExpressionFilter {
enabled: root.collectiblesList.count > 0 && !!collectiblesSearchBox.text
expression: {
let searchText = collectiblesSearchBox.text.toUpperCase()
return name.toUpperCase().startsWith(searchText)
}
model: SortFilterProxyModel {
sourceModel: root.collectiblesList
filters: ExpressionFilter {
enabled: root.collectiblesList.count > 0 && !!collectiblesSearchBox.text
expression: {
let searchText = collectiblesSearchBox.text.toUpperCase()
return name.toUpperCase().startsWith(searchText)
}
}
delegate: ActivityTypeCheckBox {
Layout.fillWidth: true
Layout.preferredHeight: 44
title: model.name
assetSettings.name: model.imageUrl
assetSettings.isImage: true
assetSettings.bgWidth: 32
assetSettings.bgHeight: 32
assetSettings.bgRadius: assetSettings.bgHeight/2
buttonGroup: collectibleButtonGroup
allChecked: root.allCollectiblesChecked
checked: root.allCollectiblesChecked || root.collectiblesFilter.includes(model.id)
onActionTriggered: root.collectibleToggled(model.id)
loading: d.isFetching
}
}
delegate: ActivityTypeCheckBox {
width: ListView.view.width
height: 44
title: model.name
assetSettings.name: model.imageUrl
assetSettings.isImage: true
assetSettings.bgWidth: 32
assetSettings.bgHeight: 32
assetSettings.bgRadius: assetSettings.bgHeight/2
buttonGroup: collectibleButtonGroup
allChecked: root.allCollectiblesChecked
checked: root.allCollectiblesChecked || root.collectiblesFilter.includes(model.id)
onActionTriggered: root.collectibleToggled(model.id)
loading: d.isFetching
}
}
}

View File

@ -7,8 +7,10 @@ import utils 1.0
QtObject {
id: root
property var transactionsList: walletSection.activityController.model
property var activityController: walletSection.activityController
property bool filtersSet: fromTimestamp !== 0 || toTimestamp !== 0 ||
property bool filtersSet: selectedTime !== Constants.TransactionTimePeriod.All ||
typeFilters.length !== 0 ||
statusFilters.length !== 0 ||
tokensFilter.length !== 0 ||
@ -22,40 +24,58 @@ QtObject {
property double toTimestamp: new Date().valueOf()
function setSelectedTimestamp(selcTime) {
selectedTime = selcTime
var currDate = new Date() // current date
switch(selectedTime) {
case Constants.TransactionTimePeriod.All:
fromTimestamp = 0
toTimestamp = 0
break
case Constants.TransactionTimePeriod.Today:
fromTimestamp = currDate.valueOf() // Today
toTimestamp = fromTimestamp
let dt = new Date()
fromTimestamp = dt.setHours(0,0,0,0).valueOf() // Today
dt.setDate(dt.getDate() + 1) // next day...
dt.setHours(0, 0, 0, -1) // ... but just 1ms before midnight -> whole day included
toTimestamp = dt.valueOf()
break
case Constants.TransactionTimePeriod.Yesterday:
fromTimestamp = new Date().setDate(currDate.getDate() - 1).valueOf() // Yesterday
toTimestamp = fromTimestamp
let dt1 = new Date()
dt1.setDate(dt1.getDate() - 1)
dt1.setHours(0, 0, 0, 0)
fromTimestamp = dt1.valueOf() // Yesterday
dt1.setDate(dt1.getDate() + 1)
dt1.setHours(0, 0, 0, -1)
toTimestamp = dt1.valueOf()
break
case Constants.TransactionTimePeriod.ThisWeek:
var firstDayOfCurrentWeek = currDate.getDate() - currDate.getDay()
fromTimestamp = new Date().setDate(firstDayOfCurrentWeek).valueOf() // This week
toTimestamp = currDate.valueOf()
let dt2 = new Date()
let firstDayOfCurrentWeek = dt2.getDate() - dt2.getDay()
dt2.setDate(firstDayOfCurrentWeek)
dt2.setHours(0, 0, 0, 0)
fromTimestamp = dt2.valueOf() // This week
toTimestamp = new Date().valueOf()
break
case Constants.TransactionTimePeriod.LastWeek:
fromTimestamp = new Date().setDate(currDate.getDate() - 7).valueOf() // Last week
toTimestamp = currDate.valueOf()
let dt3 = new Date()
dt3.setDate(dt3.getDate() - 7)
dt3.setHours(0, 0, 0, 0)
fromTimestamp = dt3.valueOf() // Last week
toTimestamp = new Date().valueOf()
break
case Constants.TransactionTimePeriod.ThisMonth:
fromTimestamp = new Date().setDate(1).valueOf() // This month
toTimestamp = currDate.valueOf()
let dt4 = new Date()
dt4.setDate(1)
dt4.setHours(0, 0, 0, 0)
fromTimestamp = dt4.valueOf() // This month
toTimestamp = new Date().valueOf()
break
case Constants.TransactionTimePeriod.LastMonth:
let x = new Date()
x.setDate(1)
x.setMonth(x.getMonth()-1)
fromTimestamp = x.valueOf() // Last month
x.setDate(new Date(x.getFullYear(), x.getMonth(), 0).getDate() + 1)
toTimestamp = x.valueOf()
let dt5 = new Date()
dt5.setDate(1)
dt5.setMonth(dt5.getMonth()-1)
dt5.setHours(0, 0, 0, 0)
fromTimestamp = dt5.valueOf() // Last month
dt5.setDate(new Date(dt5.getFullYear(), dt5.getMonth(), 0).getDate() + 2)
dt5.setHours(0, 0, 0, -1)
toTimestamp = dt5.valueOf()
break
default:
return ""
@ -115,13 +135,14 @@ QtObject {
}
// To-do get correct model unaffected by filters from go side
property var recentsList: []
property var recentsList: activityController.recipientsModel
property var recentsFilters: []
function updateRecipientsModel() {
activityController.updateRecipientsModel()
}
function toggleRecents(address) {
// update filters
recentsFilters = toggleFilterState(recentsFilters, address, recentsList.count)
// Set backend values
activityController.setFilterToAddresses(JSON.stringify(recentsFilters.concat(savedAddressFilters)))
activityController.updateFilter()
}
@ -176,4 +197,29 @@ QtObject {
function updateFilterBase() {
activityController.updateFilterBase()
}
function resetAllFilters() {
selectedTime = Constants.TransactionTimePeriod.All
fromTimestamp = activityController.startTimestamp * 1000
toTimestamp = new Date().valueOf()
activityController.setFilterTime(fromTimestamp/1000, toTimestamp/1000)
typeFilters = []
activityController.setFilterType(JSON.stringify(typeFilters))
statusFilters = []
activityController.setFilterStatus(JSON.stringify(statusFilters))
tokensFilter = []
activityController.setFilterAssets(JSON.stringify(tokensFilter), false)
collectiblesFilter = []
// To-do call update filter for collectibles
recentsFilters = []
savedAddressFilters = []
activityController.setFilterToAddresses(JSON.stringify(recentsFilters.concat(savedAddressFilters)))
activityController.updateFilter()
}
}

View File

@ -64,14 +64,13 @@ ColumnLayout {
text: qsTr("Activity for this account will appear here")
}
// Tp-do make connections with nim once logic is ready
ActivityFilterPanel {
id: filterComponent
visible: !d.isLoading && (transactionListRoot.count !== 0 || d.activityFiltersStore.filtersSet)
Layout.fillWidth: true
Layout.preferredHeight: 50
activityFilterStore: d.activityFiltersStore
store: WalletStores.RootStore
isLoading: d.isLoading
}
Item {