From 296b42a13facac60374fc3268ad8604d65a965c4 Mon Sep 17 00:00:00 2001 From: Mike Dilger Date: Sat, 14 Dec 2024 18:19:47 +1300 Subject: [PATCH] cleanup --- gossip-lib/src/feed/mod.rs | 21 +++++++++------------ gossip-lib/src/storage/mod.rs | 8 ++------ 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/gossip-lib/src/feed/mod.rs b/gossip-lib/src/feed/mod.rs index cd621608..d4d219ef 100644 --- a/gossip-lib/src/feed/mod.rs +++ b/gossip-lib/src/feed/mod.rs @@ -381,7 +381,7 @@ impl Feed { let events = if filter.authors.is_empty() { Default::default() } else { - Self::load_event_range(anchor, filter, with_replies, false, |_| true).await? + Self::load_event_range(anchor, filter, with_replies, |_| true).await? }; *self.current_feed_events.write_arc() = events; @@ -412,7 +412,7 @@ impl Feed { filter }; - let events = Self::load_event_range(anchor, filter, true, false, |_| true).await?; + let events = Self::load_event_range(anchor, filter, true, |_| true).await?; *self.current_feed_events.write_arc() = events; } @@ -437,7 +437,7 @@ impl Feed { } }; - let screen = |e: &Event| basic_screen(e, true, false, &dismissed) && screen_spam(e); + let screen = |e: &Event| basic_screen(e, true, &dismissed) && screen_spam(e); let events = GLOBALS.db().load_volatile_events(screen); *self.current_feed_events.write_arc() = events.iter().map(|e| e.id).collect(); @@ -498,7 +498,7 @@ impl Feed { )) }; - let events = Self::load_event_range(anchor, filter, true, false, screen).await?; + let events = Self::load_event_range(anchor, filter, true, screen).await?; *self.current_inbox_events.write_arc() = events; } @@ -513,7 +513,6 @@ impl Feed { since: Unixtime, filter: Filter, include_replies: bool, - include_dms: bool, screen: F, ) -> Result, Error> where @@ -523,8 +522,7 @@ impl Feed { let limit = GLOBALS.db().read_setting_load_more_count() as usize; let dismissed = GLOBALS.dismissed.read().await.clone(); - let outer_screen = - |e: &Event| basic_screen(e, include_replies, include_dms, &dismissed) && screen(e); + let outer_screen = |e: &Event| basic_screen(e, include_replies, &dismissed) && screen(e); let mut before_filter = filter; let mut after_filter = before_filter.clone(); @@ -552,15 +550,14 @@ impl Feed { } #[inline] -fn basic_screen(e: &Event, include_replies: bool, include_dms: bool, dismissed: &[Id]) -> bool { +fn basic_screen(e: &Event, include_replies: bool, dismissed: &[Id]) -> bool { let now = Unixtime::now(); e.created_at <= now && (include_replies || e.replies_to().is_none()) - && (include_dms - || (e.kind != EventKind::EncryptedDirectMessage - && e.kind != EventKind::DmChat - && e.kind != EventKind::GiftWrap)) + && e.kind != EventKind::EncryptedDirectMessage + && e.kind != EventKind::DmChat + && e.kind != EventKind::GiftWrap && !dismissed.contains(&e.id) && !e.is_annotation() } diff --git a/gossip-lib/src/storage/mod.rs b/gossip-lib/src/storage/mod.rs index 54e3d56d..331cfd5b 100644 --- a/gossip-lib/src/storage/mod.rs +++ b/gossip-lib/src/storage/mod.rs @@ -1539,12 +1539,8 @@ impl Storage { tagname.push(*ftag.0); let iter = { - let start_prefix = TciKey::from_parts( - &tagname, &ftag.1[0], until, Id([0; 32]) - ); - let end_prefix = TciKey::from_parts( - &tagname, &ftag.1[0], since, Id([255; 32]) - ); + let start_prefix = TciKey::from_parts(&tagname, &ftag.1[0], until, Id([0; 32])); + let end_prefix = TciKey::from_parts(&tagname, &ftag.1[0], since, Id([255; 32])); let range = ( Bound::Included(start_prefix.as_slice()), Bound::Excluded(end_prefix.as_slice()),