From 030e4226f844320f2760db640215c1eda4f7adea Mon Sep 17 00:00:00 2001 From: kernelkind Date: Thu, 17 Jul 2025 18:15:28 -0400 Subject: [PATCH 1/2] appease clippy ``` error: large size difference between variants --> crates/notedeck_columns/src/column.rs:249:1 | 249 | / pub enum IntermediaryRoute { 250 | | Timeline(Timeline), | | ------------------ the largest variant contains at least 280 bytes 251 | | Route(Route), | | ------------ the second-largest variant contains at least 72 bytes 252 | | } | |_^ the entire enum is at least 280 bytes | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#large_enum_variant = note: `-D clippy::large-enum-variant` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::large_enum_variant)]` help: consider boxing the large fields to reduce the total size of the enum | 250 - Timeline(Timeline), 250 + Timeline(Box), | error: could not compile `notedeck_columns` (lib) due to 1 previous error ``` Signed-off-by: kernelkind --- crates/notedeck_columns/src/column.rs | 4 ++-- crates/notedeck_columns/src/storage/decks.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/notedeck_columns/src/column.rs b/crates/notedeck_columns/src/column.rs index dbc5c09..902cc02 100644 --- a/crates/notedeck_columns/src/column.rs +++ b/crates/notedeck_columns/src/column.rs @@ -124,7 +124,7 @@ impl Columns { IntermediaryRoute::Timeline(mut timeline) => { let route = Route::timeline(timeline.kind.clone()); timeline.subscription.increment(); - timeline_cache.insert(timeline.kind.clone(), timeline); + timeline_cache.insert(timeline.kind.clone(), *timeline); route } IntermediaryRoute::Route(route) => route, @@ -247,7 +247,7 @@ impl Columns { } pub enum IntermediaryRoute { - Timeline(Timeline), + Timeline(Box), Route(Route), } diff --git a/crates/notedeck_columns/src/storage/decks.rs b/crates/notedeck_columns/src/storage/decks.rs index c25b92d..00f3c6e 100644 --- a/crates/notedeck_columns/src/storage/decks.rs +++ b/crates/notedeck_columns/src/storage/decks.rs @@ -351,9 +351,9 @@ impl CleanIntermediaryRoute { match self { CleanIntermediaryRoute::ToTimeline(timeline_kind) => { let txn = Transaction::new(ndb).unwrap(); - Some(IntermediaryRoute::Timeline( + Some(IntermediaryRoute::Timeline(Box::new( timeline_kind.into_timeline(&txn, ndb)?, - )) + ))) } CleanIntermediaryRoute::ToRoute(route) => Some(IntermediaryRoute::Route(route)), } From fdef74c3535639d4ec25d1620aadb12f21b624eb Mon Sep 17 00:00:00 2001 From: kernelkind Date: Thu, 17 Jul 2025 18:16:06 -0400 Subject: [PATCH 2/2] fix: sometimes most recent contacts list wasn't used `ndb::poll_for_notes` appears to give notes as they arrive. We need to make sure we only use the most recent for contacts Signed-off-by: kernelkind --- crates/notedeck/src/account/contacts.rs | 22 ++++++++++++++++++++- crates/notedeck_columns/src/profile.rs | 1 + crates/notedeck_columns/src/timeline/mod.rs | 2 ++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/crates/notedeck/src/account/contacts.rs b/crates/notedeck/src/account/contacts.rs index 0a7136a..2c70493 100644 --- a/crates/notedeck/src/account/contacts.rs +++ b/crates/notedeck/src/account/contacts.rs @@ -13,6 +13,7 @@ pub enum ContactState { Received { contacts: HashSet, note_key: NoteKey, + timestamp: u64, }, } @@ -55,6 +56,7 @@ impl Contacts { ContactState::Received { contacts, note_key: _, + timestamp: _, } => { if contacts.contains(other_pubkey) { IsFollowing::Yes @@ -80,6 +82,18 @@ impl Contacts { } }; + if let ContactState::Received { + contacts: _, + note_key: _, + timestamp, + } = self.get_state() + { + if *timestamp > note.created_at() { + // the current contact list is more up to date than the one we just received. ignore it. + return; + } + } + update_state(&mut self.state, ¬e, *key); } @@ -94,11 +108,17 @@ fn update_state(state: &mut ContactState, note: &Note, key: NoteKey) { *state = ContactState::Received { contacts: get_contacts_owned(note), note_key: key, + timestamp: note.created_at(), }; } - ContactState::Received { contacts, note_key } => { + ContactState::Received { + contacts, + note_key, + timestamp, + } => { update_contacts(contacts, note); *note_key = key; + *timestamp = note.created_at(); } }; } diff --git a/crates/notedeck_columns/src/profile.rs b/crates/notedeck_columns/src/profile.rs index 9bd6c6d..5d068bf 100644 --- a/crates/notedeck_columns/src/profile.rs +++ b/crates/notedeck_columns/src/profile.rs @@ -144,6 +144,7 @@ fn send_kind_3_event(ndb: &Ndb, pool: &mut RelayPool, accounts: &Accounts, actio let ContactState::Received { contacts: _, note_key, + timestamp: _, } = accounts.get_selected_account().data.contacts.get_state() else { return; diff --git a/crates/notedeck_columns/src/timeline/mod.rs b/crates/notedeck_columns/src/timeline/mod.rs index 824484a..bc2575c 100644 --- a/crates/notedeck_columns/src/timeline/mod.rs +++ b/crates/notedeck_columns/src/timeline/mod.rs @@ -601,6 +601,7 @@ pub fn fetch_contact_list( ContactState::Received { contacts: _, note_key: _, + timestamp: _, } => FilterState::GotRemote(filter::GotRemoteType::Contact), }; @@ -718,6 +719,7 @@ pub fn is_timeline_ready( let ContactState::Received { contacts: _, note_key, + timestamp: _, } = accounts.get_selected_account().data.contacts.get_state() else { return false;