mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-30 00:41:42 +00:00
minor optimization
This commit is contained in:
parent
ed8b54e664
commit
08fd01f5b8
16
src/feed.rs
16
src/feed.rs
@ -237,26 +237,26 @@ impl Feed {
|
|||||||
let now = Unixtime::now().unwrap();
|
let now = Unixtime::now().unwrap();
|
||||||
let dismissed = GLOBALS.dismissed.read().await.clone();
|
let dismissed = GLOBALS.dismissed.read().await.clone();
|
||||||
|
|
||||||
let mut gevents: Vec<Event> = events
|
let mut gevents: Vec<(Unixtime, Id)> = events
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|e| !dismissed.contains(&e.id))
|
.filter(|e| !dismissed.contains(&e.id))
|
||||||
.filter(|e| followed_pubkeys.contains(&e.pubkey.into())) // something we follow
|
.filter(|e| followed_pubkeys.contains(&e.pubkey.into())) // something we follow
|
||||||
.filter(|e| e.created_at <= now)
|
.filter(|e| e.created_at <= now)
|
||||||
.cloned()
|
.map(|e| (e.created_at, e.id))
|
||||||
.collect();
|
.collect();
|
||||||
gevents.sort_by(|a, b| b.created_at.cmp(&a.created_at));
|
gevents.sort_by(|a, b| b.0.cmp(&a.0));
|
||||||
*self.general_feed.write() = gevents.iter().map(|e| e.id).collect();
|
*self.general_feed.write() = gevents.iter().map(|e| e.1).collect();
|
||||||
|
|
||||||
let mut mevents: Vec<Event> = events
|
let mut mevents: Vec<(Unixtime, Id)> = events
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|e| !dismissed.contains(&e.id))
|
.filter(|e| !dismissed.contains(&e.id))
|
||||||
.filter(|e| { !matches!(e.replies_to(), Some((_id, _))) })
|
.filter(|e| { !matches!(e.replies_to(), Some((_id, _))) })
|
||||||
.filter(|e| followed_pubkeys.contains(&e.pubkey.into())) // something we follow
|
.filter(|e| followed_pubkeys.contains(&e.pubkey.into())) // something we follow
|
||||||
.filter(|e| e.created_at <= now)
|
.filter(|e| e.created_at <= now)
|
||||||
.cloned()
|
.map(|e| (e.created_at, e.id))
|
||||||
.collect();
|
.collect();
|
||||||
mevents.sort_by(|a, b| b.created_at.cmp(&a.created_at));
|
mevents.sort_by(|a, b| b.0.cmp(&a.0));
|
||||||
*self.main_feed.write() = mevents.iter().map(|e| e.id).collect();
|
*self.main_feed.write() = mevents.iter().map(|e| e.1).collect();
|
||||||
|
|
||||||
// Filter differently for the replies feed
|
// Filter differently for the replies feed
|
||||||
let direct_only = GLOBALS.settings.read().direct_replies_only;
|
let direct_only = GLOBALS.settings.read().direct_replies_only;
|
||||||
|
Loading…
Reference in New Issue
Block a user