From d03cf859e1ea8bd8d502148c7648199c9d670298 Mon Sep 17 00:00:00 2001 From: Mike Dilger Date: Tue, 3 Jan 2023 14:27:45 +1300 Subject: [PATCH] Remove globals.last_reply, we no longer need it --- src/globals.rs | 19 +------------------ src/process.rs | 12 ------------ 2 files changed, 1 insertion(+), 30 deletions(-) diff --git a/src/globals.rs b/src/globals.rs index b3f6ab10..1db9d829 100644 --- a/src/globals.rs +++ b/src/globals.rs @@ -7,7 +7,7 @@ use crate::people::People; use crate::relationship::Relationship; use crate::settings::Settings; use crate::signer::Signer; -use nostr_types::{Event, Id, IdHex, PublicKeyHex, Unixtime, Url}; +use nostr_types::{Event, Id, IdHex, PublicKeyHex, Url}; use rusqlite::Connection; use std::collections::{HashMap, HashSet}; use std::sync::atomic::AtomicBool; @@ -40,10 +40,6 @@ pub struct Globals { /// All relationships between events pub relationships: RwLock>>, - /// The date of the latest reply. Only reply relationships count, not reactions, - /// deletions, or quotes - pub last_reply: RwLock>, - /// Desired events, referred to by others, with possible URLs where we can /// get them. We may already have these, but if not we should ask for them. pub desired_events: RwLock>>, @@ -97,7 +93,6 @@ lazy_static! { events: RwLock::new(HashMap::new()), incoming_events: RwLock::new(Vec::new()), relationships: RwLock::new(HashMap::new()), - last_reply: RwLock::new(HashMap::new()), desired_events: RwLock::new(HashMap::new()), people: RwLock::new(People::new()), relays: RwLock::new(HashMap::new()), @@ -227,18 +222,6 @@ impl Globals { .or_insert_with(|| vec![r]); } - pub async fn update_last_reply(id: Id, time: Unixtime) { - let mut last_reply = GLOBALS.last_reply.write().await; - last_reply - .entry(id) - .and_modify(|lasttime| { - if time > *lasttime { - *lasttime = time; - } - }) - .or_insert_with(|| time); - } - pub fn get_replies_sync(id: Id) -> Vec { let mut output: Vec = Vec::new(); if let Some(vec) = GLOBALS.relationships.blocking_read().get(&id) { diff --git a/src/process.rs b/src/process.rs index f54fe362..1b4c10ff 100644 --- a/src/process.rs +++ b/src/process.rs @@ -141,18 +141,6 @@ pub async fn process_new_event( // Insert into relationships Globals::add_relationship(id, event.id, Relationship::Reply).await; - - // Update last_reply - let mut id = id; - Globals::update_last_reply(id, event.created_at).await; - while let Some(ev) = GLOBALS.events.read().await.get(&id).cloned() { - if let Some((pid, _)) = ev.replies_to() { - id = pid; - Globals::update_last_reply(id, event.created_at).await; - } else { - break; - } - } } // We desire all ancestors