mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-19 11:43:43 +00:00
Fix following feed pollution
This commit is contained in:
parent
341af37e7d
commit
3a767f05fc
12
src/feed.rs
12
src/feed.rs
@ -146,6 +146,11 @@ impl Feed {
|
|||||||
.map(|e| e.to_owned())
|
.map(|e| e.to_owned())
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
let mut pubkeys = GLOBALS.people.blocking_read().get_followed_pubkeys();
|
||||||
|
if let Some(pubkey) = GLOBALS.signer.blocking_read().public_key() {
|
||||||
|
pubkeys.push(pubkey.into()); // add the user
|
||||||
|
}
|
||||||
|
|
||||||
// My event ids
|
// My event ids
|
||||||
if let Some(pubkey) = GLOBALS.signer.blocking_read().public_key() {
|
if let Some(pubkey) = GLOBALS.signer.blocking_read().public_key() {
|
||||||
*self.my_event_ids.write() = events
|
*self.my_event_ids.write() = events
|
||||||
@ -157,11 +162,10 @@ impl Feed {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Followed event ids
|
// Followed event ids
|
||||||
let followed_pubkeys = GLOBALS.people.blocking_read().get_followed_pubkeys();
|
|
||||||
*self.followed_event_ids.write() = events
|
*self.followed_event_ids.write() = events
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|e| {
|
.filter_map(|e| {
|
||||||
if followed_pubkeys.contains(&e.pubkey.into()) {
|
if pubkeys.contains(&e.pubkey.into()) {
|
||||||
Some(e.id)
|
Some(e.id)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
@ -172,11 +176,13 @@ impl Feed {
|
|||||||
// Filter further for the feed
|
// Filter further for the feed
|
||||||
let mut events: Vec<Event> = events
|
let mut events: Vec<Event> = events
|
||||||
.iter()
|
.iter()
|
||||||
|
.filter(|e| pubkeys.contains(&e.pubkey.into())) // something we follow
|
||||||
.filter(|e| !GLOBALS.dismissed.blocking_read().contains(&e.id))
|
.filter(|e| !GLOBALS.dismissed.blocking_read().contains(&e.id))
|
||||||
.cloned()
|
.cloned()
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
events.sort_unstable_by(|a, b| b.created_at.cmp(&a.created_at));
|
// In time order
|
||||||
|
events.sort_by(|a, b| b.created_at.cmp(&a.created_at));
|
||||||
|
|
||||||
*self.general_feed.write() = events.iter().map(|e| e.id).collect();
|
*self.general_feed.write() = events.iter().map(|e| e.id).collect();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user