mirror of
https://github.com/aljazceru/notedeck.git
synced 2025-12-19 09:34:19 +01:00
bugfix: unsubscribe all decks when log out account
Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user