mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-19 11:43:43 +00:00
Fix missing tagged events in the replies feed (may still repeat events, but this is better than missing them)
This commit is contained in:
parent
dd4446f6a8
commit
a06380946c
36
src/feed.rs
36
src/feed.rs
@ -209,23 +209,27 @@ impl Feed {
|
||||
*self.general_feed.write() = fevents.iter().map(|e| e.id).collect();
|
||||
|
||||
// Filter differently for the replies feed
|
||||
let my_events: HashSet<Id> = self.my_event_ids.read().iter().copied().collect();
|
||||
let mut revents: Vec<Event> = events
|
||||
.iter()
|
||||
.filter(|e| !dismissed.contains(&e.id))
|
||||
.filter(|e| {
|
||||
// FIXME: maybe try replies_to_ancestors to go deeper
|
||||
if let Some((id, _)) = e.replies_to() {
|
||||
if my_events.contains(&id) {
|
||||
return true;
|
||||
if let Some(my_pubkey) = GLOBALS.signer.read().await.public_key() {
|
||||
let my_events: HashSet<Id> = self.my_event_ids.read().iter().copied().collect();
|
||||
let mut revents: Vec<Event> = events
|
||||
.iter()
|
||||
.filter(|e| !dismissed.contains(&e.id))
|
||||
.filter(|e| {
|
||||
// Include if it directly replies to one of my events
|
||||
// FIXME: maybe try replies_to_ancestors to go deeper
|
||||
if let Some((id, _)) = e.replies_to() {
|
||||
if my_events.contains(&id) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
false
|
||||
})
|
||||
.cloned()
|
||||
.collect();
|
||||
revents.sort_by(|a, b| b.created_at.cmp(&a.created_at));
|
||||
*self.replies_feed.write() = revents.iter().map(|e| e.id).collect();
|
||||
// Include if it tags me
|
||||
e.people().iter().any(|(p, _, _)| *p == my_pubkey.into())
|
||||
})
|
||||
.cloned()
|
||||
.collect();
|
||||
revents.sort_by(|a, b| b.created_at.cmp(&a.created_at));
|
||||
*self.replies_feed.write() = revents.iter().map(|e| e.id).collect();
|
||||
}
|
||||
|
||||
// Potentially update thread parent to a higher parent
|
||||
let maybe_tp = *self.thread_parent.read();
|
||||
|
@ -132,11 +132,16 @@ impl Overlord {
|
||||
let now = Unixtime::now().unwrap();
|
||||
let feed_chunk = GLOBALS.settings.read().await.feed_chunk;
|
||||
let then = now.0 - feed_chunk as i64;
|
||||
let db_events = DbEvent::fetch(Some(&format!(
|
||||
" (kind=1 OR kind=5 OR kind=7) AND created_at > {} ORDER BY created_at ASC",
|
||||
then
|
||||
)))
|
||||
.await?;
|
||||
|
||||
let cond = if GLOBALS.settings.read().await.reactions {
|
||||
format!(" (kind=1 OR kind=5 OR kind=6 OR kind=7) AND created_at > {} ORDER BY created_at ASC", then)
|
||||
} else {
|
||||
format!(
|
||||
" (kind=1 OR kind=5 OR kind=6) AND created_at > {} ORDER BY created_at ASC",
|
||||
then
|
||||
)
|
||||
};
|
||||
let db_events = DbEvent::fetch(Some(&cond)).await?;
|
||||
|
||||
// Map db events into Events
|
||||
let mut events: Vec<Event> = Vec::with_capacity(db_events.len());
|
||||
|
Loading…
Reference in New Issue
Block a user