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

View File

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

View File

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

View File

@ -107,6 +107,7 @@ type
hasMarketValuesCache*: bool
removed*: bool # needs for synchronization
operable*: string
createdAt*: int
proc toWalletAccountDto*(jsonObj: JsonNode): WalletAccountDto =
result = WalletAccountDto()
@ -124,6 +125,7 @@ proc toWalletAccountDto*(jsonObj: JsonNode): WalletAccountDto =
discard jsonObj.getProp("emoji", result.emoji)
discard jsonObj.getProp("removed", result.removed)
discard jsonObj.getProp("operable", result.operable)
discard jsonObj.getProp("createdAt", result.createdAt)
result.assetsLoading = true
result.hasBalanceCache = 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
const showCmd: int32 = 5
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.Layouts 1.13
import QtGraphicalEffects 1.13
import SortFilterProxyModel 0.2
import StatusQ.Core 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 }
}
}
}
}