Cache-invalidate all posts by a given author when toggling mute

This commit is contained in:
Mike Dilger 2023-04-07 11:12:06 +12:00
parent db460338bc
commit 1d09e35737
2 changed files with 16 additions and 1 deletions

View File

@ -206,11 +206,25 @@ impl Notes {
}
}
/*
/// Drop NoteData objects that do not have a
/// correlated event in the event cache
pub(super) fn drop_uncached_events(&mut self) {
pub(super) fn cache_invalidate_missing_events(&mut self) {
self.notes.retain(|id,_| GLOBALS.events.contains_key(id));
}
*/
/*
/// Drop NoteData for a specific note
pub(super) fn cache_invalidate_note(&mut self, id: &Id) {
self.notes.remove(id);
}
*/
/// Drop all NoteData for a given person
pub(in crate::ui) fn cache_invalidate_person(&mut self, pubkey: &PublicKeyHex) {
self.notes.retain(|_,note| note.borrow().author.pubkey != *pubkey);
}
pub(super) fn try_update_and_get(&mut self, id: &Id) -> Option<Rc<RefCell<NoteData>>> {
if self.notes.contains_key(id) {

View File

@ -623,6 +623,7 @@ impl GossipUi {
let mute_label = if person.muted == 1 { "Unmute" } else { "Mute" };
if ui.button(mute_label).clicked() {
GLOBALS.people.mute(&person.pubkey, person.muted == 0);
app.notes.cache_invalidate_person(&person.pubkey);
}
if person.followed == 0 && ui.button("Follow").clicked() {
GLOBALS.people.follow(&person.pubkey, true);