commit 8daa1d2adfabb8c6f18a1dfc453329ce75f1f98a
parent b9cae65b72de14ee9cf16035a06983bf45da72f7
Author: kernelkind <kernelkind@gmail.com>
Date: Thu, 17 Jul 2025 19:24:33 -0400
allow removal of Damoose account
Signed-off-by: kernelkind <kernelkind@gmail.com>
Diffstat:
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/crates/notedeck/src/account/cache.rs b/crates/notedeck/src/account/cache.rs
@@ -6,6 +6,7 @@ use crate::{SingleUnkIdAction, UserAccount};
pub struct AccountCache {
selected: Pubkey,
fallback: Pubkey,
+ fallback_account: UserAccount,
// never empty at rest
accounts: HashMap<Pubkey, UserAccount>,
@@ -16,12 +17,13 @@ impl AccountCache {
let mut accounts = HashMap::with_capacity(1);
let pk = fallback.key.pubkey;
- accounts.insert(pk, fallback);
+ accounts.insert(pk, fallback.clone());
(
Self {
selected: pk,
fallback: pk,
+ fallback_account: fallback,
accounts,
},
SingleUnkIdAction::pubkey(pk),
@@ -49,13 +51,18 @@ impl AccountCache {
}
pub(super) fn remove(&mut self, pk: &Pubkey) -> Option<UserAccount> {
- // fallback account should never be removed
- if *pk == self.fallback {
+ if *pk == self.fallback && self.accounts.len() == 1 {
+ // no point in removing it since it'll just get re-added anyway
return None;
}
let removed = self.accounts.remove(pk);
+ if self.accounts.is_empty() {
+ self.accounts
+ .insert(self.fallback, self.fallback_account.clone());
+ }
+
if removed.is_some() && self.selected == *pk {
// TODO(kernelkind): choose next better
let (next, _) = self