fix(@wallet): delete selected account

This commit is contained in:
Anthony Laibe 2023-04-24 18:20:27 +02:00 committed by Anthony Laibe
parent c94997ddec
commit bdaf122ec7
1 changed files with 6 additions and 3 deletions

View File

@ -95,9 +95,11 @@ proc setBalance(self: Module, tokens: seq[WalletTokenDto]) =
# TODO(alaibe): replace with filter logic
method switchAccount*(self: Module, accountIndex: int) =
var walletAccount = self.controller.getWalletAccount(accountIndex)
self.currentAccountIndex = accountIndex
let walletAccount = self.controller.getWalletAccount(accountIndex)
if walletAccount.isNil:
self.currentAccountIndex = 0
walletAccount = self.controller.getWalletAccount(self.currentAccountIndex)
let item = initItem(
walletAccount.name,
@ -133,4 +135,5 @@ proc onAccountAdded(self: Module, account: WalletAccountDto) =
self.switchAccount(self.currentAccountIndex)
proc onAccountRemoved(self: Module, account: WalletAccountDto) =
self.switchAccount(self.currentAccountIndex)
self.switchAccount(self.currentAccountIndex)