fix(@wallet): prevent delete main account

fixes #11398
This commit is contained in:
Anthony Laibe 2023-07-04 14:17:42 +02:00 committed by Anthony Laibe
parent 16f3f0b2eb
commit 0cd7829d62
4 changed files with 13 additions and 2 deletions

View File

@ -10,6 +10,7 @@ type
createdAt: int
assetsLoading: bool
currencyBalance: CurrencyAmount
isWallet: bool
proc initItem*(
name: string = "",
@ -23,7 +24,8 @@ proc initItem*(
createdAt: int = 0,
position: int = 0,
keycardAccount: bool = false,
assetsLoading: bool = true,
assetsLoading: bool = true,
isWallet: bool = false,
): Item =
result = Item()
result.WalletAccountItem.setup(name,
@ -38,6 +40,7 @@ proc initItem*(
result.position = position
result.assetsLoading = assetsLoading
result.currencyBalance = currencyBalance
result.isWallet = isWallet
proc `$`*(self: Item): string =
result = "WalletSection-Accounts-Item("
@ -57,3 +60,6 @@ proc createdAt*(self: Item): int =
proc position*(self: Item): int =
return self.position
proc isWallet*(self: Item): bool =
return self.isWallet

View File

@ -18,6 +18,7 @@ type
Position,
KeycardAccount,
AssetsLoading,
IsWallet,
QtObject:
type
@ -66,6 +67,7 @@ QtObject:
ModelRole.Position.int: "position",
ModelRole.KeycardAccount.int: "keycardAccount",
ModelRole.AssetsLoading.int: "assetsLoading",
ModelRole.IsWallet.int: "isWallet",
}.toTable
@ -113,6 +115,8 @@ QtObject:
result = newQVariant(item.keycardAccount())
of ModelRole.AssetsLoading:
result = newQVariant(item.assetsLoading())
of ModelRole.IsWallet:
result = newQVariant(item.isWallet())
proc getNameByAddress*(self: Model, address: string): string =
for item in self.items:

View File

@ -69,6 +69,7 @@ proc walletAccountToWalletAccountsItem*(w: WalletAccountDto, keycardAccount: boo
w.position,
keycardAccount,
w.assetsLoading,
w.isWallet
)
proc walletAccountToWalletAssetsItem*(w: WalletAccountDto): wallet_assets_item.Item =

View File

@ -45,7 +45,7 @@ StatusMenu {
StatusAction {
objectName: "AccountMenu-DeleteAction-%1".arg(root.uniqueIdentifier)
enabled: !!root.account && root.account.walletType !== ""
enabled: !!root.account && !root.account.isWallet
text: qsTr("Delete")
icon.name: "info"
type: StatusAction.Type.Danger