feat(@wallet): sort accounts

fixes #10845
This commit is contained in:
Anthony Laibe 2023-06-02 09:40:58 +02:00 committed by Anthony Laibe
parent 197f5f74d5
commit 525a8e19bf
6 changed files with 21 additions and 1 deletions

View File

@ -6,6 +6,7 @@ export wallet_account_item
type type
Item* = ref object of WalletAccountItem Item* = ref object of WalletAccountItem
createdAt: int
assetsLoading: bool assetsLoading: bool
currencyBalance: CurrencyAmount currencyBalance: CurrencyAmount
@ -18,6 +19,7 @@ proc initItem*(
currencyBalance: CurrencyAmount = nil, currencyBalance: CurrencyAmount = nil,
emoji: string = "", emoji: string = "",
keyUid: string = "", keyUid: string = "",
createdAt: int = 0,
keycardAccount: bool = false, keycardAccount: bool = false,
assetsLoading: bool = true, assetsLoading: bool = true,
): Item = ): Item =
@ -30,6 +32,7 @@ proc initItem*(
path, path,
keyUid, keyUid,
keycardAccount) keycardAccount)
result.createdAt = createdAt
result.assetsLoading = assetsLoading result.assetsLoading = assetsLoading
result.currencyBalance = currencyBalance result.currencyBalance = currencyBalance
@ -45,3 +48,6 @@ proc currencyBalance*(self: Item): CurrencyAmount =
proc assetsLoading*(self: Item): bool = proc assetsLoading*(self: Item): bool =
return self.assetsLoading return self.assetsLoading
proc createdAt*(self: Item): int =
return self.createdAt

View File

@ -14,6 +14,7 @@ type
CurrencyBalance, CurrencyBalance,
Emoji, Emoji,
KeyUid, KeyUid,
CreatedAt,
KeycardAccount, KeycardAccount,
AssetsLoading, AssetsLoading,
@ -60,6 +61,7 @@ QtObject:
ModelRole.CurrencyBalance.int:"currencyBalance", ModelRole.CurrencyBalance.int:"currencyBalance",
ModelRole.Emoji.int: "emoji", ModelRole.Emoji.int: "emoji",
ModelRole.KeyUid.int: "keyUid", ModelRole.KeyUid.int: "keyUid",
ModelRole.CreatedAt.int: "createdAt",
ModelRole.KeycardAccount.int: "keycardAccount", ModelRole.KeycardAccount.int: "keycardAccount",
ModelRole.AssetsLoading.int: "assetsLoading", ModelRole.AssetsLoading.int: "assetsLoading",
}.toTable }.toTable
@ -101,6 +103,8 @@ QtObject:
result = newQVariant(item.emoji()) result = newQVariant(item.emoji())
of ModelRole.KeyUid: of ModelRole.KeyUid:
result = newQVariant(item.keyUid()) result = newQVariant(item.keyUid())
of ModelRole.CreatedAt:
result = newQVariant(item.createdAt())
of ModelRole.KeycardAccount: of ModelRole.KeycardAccount:
result = newQVariant(item.keycardAccount()) result = newQVariant(item.keycardAccount())
of ModelRole.AssetsLoading: of ModelRole.AssetsLoading:

View File

@ -64,6 +64,7 @@ proc walletAccountToWalletAccountsItem*(w: WalletAccountDto, keycardAccount: boo
currencyAmountToItem(w.getCurrencyBalance(enabledChainIds, currency), currencyFormat), currencyAmountToItem(w.getCurrencyBalance(enabledChainIds, currency), currencyFormat),
w.emoji, w.emoji,
w.keyUid, w.keyUid,
w.createdAt,
keycardAccount, keycardAccount,
w.assetsLoading, w.assetsLoading,
) )

View File

@ -107,6 +107,7 @@ type
hasMarketValuesCache*: bool hasMarketValuesCache*: bool
removed*: bool # needs for synchronization removed*: bool # needs for synchronization
operable*: string operable*: string
createdAt*: int
proc toWalletAccountDto*(jsonObj: JsonNode): WalletAccountDto = proc toWalletAccountDto*(jsonObj: JsonNode): WalletAccountDto =
result = WalletAccountDto() result = WalletAccountDto()
@ -124,6 +125,7 @@ proc toWalletAccountDto*(jsonObj: JsonNode): WalletAccountDto =
discard jsonObj.getProp("emoji", result.emoji) discard jsonObj.getProp("emoji", result.emoji)
discard jsonObj.getProp("removed", result.removed) discard jsonObj.getProp("removed", result.removed)
discard jsonObj.getProp("operable", result.operable) discard jsonObj.getProp("operable", result.operable)
discard jsonObj.getProp("createdAt", result.createdAt)
result.assetsLoading = true result.assetsLoading = true
result.hasBalanceCache = false result.hasBalanceCache = false
result.hasMarketValuesCache = false result.hasMarketValuesCache = false

View File

@ -19,4 +19,5 @@ let params = newWideCString(params_str)
# SW_SHOW (5): activates window and displays it in its current size and position # SW_SHOW (5): activates window and displays it in its current size and position
const showCmd: int32 = 5 const showCmd: int32 = 5
discard shellExecuteW(NULL, open, exePath, params, workDir, showCmd) discard shellExecuteW(NULL, open, exePath, params, workDir, showCmd)

View File

@ -2,6 +2,7 @@ import QtQuick 2.13
import QtQuick.Controls 2.13 import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13 import QtQuick.Layouts 1.13
import QtGraphicalEffects 1.13 import QtGraphicalEffects 1.13
import SortFilterProxyModel 0.2
import StatusQ.Core 0.1 import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1 import StatusQ.Core.Theme 0.1
@ -420,7 +421,12 @@ Rectangle {
} }
} }
model: RootStore.accounts model: SortFilterProxyModel {
sourceModel: RootStore.accounts
sorters: RoleSorter { roleName: "createdAt"; sortOrder: Qt.AscendingOrder }
}
} }
} }
} }