Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mikedilger committed Dec 14, 2024
1 parent 60932b3 commit 296b42a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
21 changes: 9 additions & 12 deletions gossip-lib/src/feed/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand All @@ -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();
Expand Down Expand Up @@ -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;
}

Expand All @@ -513,7 +513,6 @@ impl Feed {
since: Unixtime,
filter: Filter,
include_replies: bool,
include_dms: bool,
screen: F,
) -> Result<Vec<Id>, Error>
where
Expand All @@ -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();
Expand Down Expand Up @@ -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()
}
Expand Down
8 changes: 2 additions & 6 deletions gossip-lib/src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down

0 comments on commit 296b42a

Please sign in to comment.