Fix account deselecting itself sometimes

This commit is contained in:
Zoe Roux 2024-01-31 11:54:00 +01:00
parent a0c1fdbd74
commit b323736774

View File

@ -102,8 +102,11 @@ export const updateAccount = (id: string, account: Account) => {
const idx = accounts.findIndex((x) => x.id == id);
if (idx === -1) return;
if (account.selected) {
const selected = account.selected;
if (selected) {
for (const acc of accounts) acc.selected = false;
// if account was already on the accounts list, we keep it selected.
account.selected = selected;
} else if (accounts[idx].selected) {
// we just unselected the current account, focus another one.
if (accounts.length > 0) accounts[0].selected = true;