commit 0b27282985008fb4addf31bc724d5cb092c987df
parent 1c547bbcaa158eaa52d2c592289b2578caaabafa
Author: kernelkind <kernelkind@gmail.com>
Date: Thu, 17 Jul 2025 21:31:10 -0400
bugfix: unsubscribe all decks when log out account
Signed-off-by: kernelkind <kernelkind@gmail.com>
Diffstat:
2 files changed, 38 insertions(+), 6 deletions(-)
diff --git a/crates/notedeck_columns/src/decks.rs b/crates/notedeck_columns/src/decks.rs
@@ -1,6 +1,6 @@
use std::collections::{hash_map::ValuesMut, HashMap};
-use enostr::Pubkey;
+use enostr::{Pubkey, RelayPool};
use nostrdb::Transaction;
use notedeck::{AppContext, FALLBACK_PUBKEY};
use tracing::{error, info};
@@ -155,9 +155,24 @@ impl DecksCache {
}
}
- pub fn remove_for(&mut self, key: &Pubkey) {
+ pub fn remove(
+ &mut self,
+ key: &Pubkey,
+ timeline_cache: &mut TimelineCache,
+ ndb: &mut nostrdb::Ndb,
+ pool: &mut RelayPool,
+ ) {
+ let Some(decks) = self.account_to_decks.remove(key) else {
+ return;
+ };
info!("Removing decks for {:?}", key);
- self.account_to_decks.remove(key);
+
+ decks.unsubscribe_all(timeline_cache, ndb, pool);
+
+ if !self.account_to_decks.contains_key(&self.fallback_pubkey) {
+ self.account_to_decks
+ .insert(self.fallback_pubkey, Decks::default());
+ }
}
pub fn get_fallback_pubkey(&self) -> &Pubkey {
@@ -328,6 +343,17 @@ impl Decks {
}
res
}
+
+ pub fn unsubscribe_all(
+ self,
+ timeline_cache: &mut TimelineCache,
+ ndb: &mut nostrdb::Ndb,
+ pool: &mut enostr::RelayPool,
+ ) {
+ for deck in self.decks {
+ delete_deck(deck, timeline_cache, ndb, pool);
+ }
+ }
}
fn delete_deck(
diff --git a/crates/notedeck_columns/src/nav.rs b/crates/notedeck_columns/src/nav.rs
@@ -94,9 +94,15 @@ impl SwitchingAction {
.router_mut()
.go_back();
}
- AccountsAction::Remove(to_remove) => {
- ctx.accounts
- .remove_account(to_remove, ctx.ndb, ctx.pool, ui_ctx);
+ AccountsAction::Remove(to_remove) => 's: {
+ if !ctx
+ .accounts
+ .remove_account(to_remove, ctx.ndb, ctx.pool, ui_ctx)
+ {
+ break 's;
+ }
+
+ decks_cache.remove(to_remove, timeline_cache, ctx.ndb, ctx.pool);
}
},
SwitchingAction::Columns(columns_action) => match *columns_action {