notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

commit 8773b5d44ddad63716858d53f5513a1198fc69c2
parent ea31cdc33a3de9fde57d7a4c682ed768d6aa583b
Author: kernelkind <kernelkind@gmail.com>
Date:   Thu, 26 Feb 2026 16:56:25 -0500

refactor(messages): remove unused conversation cache loaders

Diffstat:
Mcrates/notedeck_messages/src/cache/conversation.rs | 98++-----------------------------------------------------------------------------
1 file changed, 2 insertions(+), 96 deletions(-)

diff --git a/crates/notedeck_messages/src/cache/conversation.rs b/crates/notedeck_messages/src/cache/conversation.rs @@ -9,13 +9,13 @@ use crate::{ }, }, convo_renderable::ConversationRenderable, - nip17::{chatroom_filter, conversation_filter, get_participants}, + nip17::get_participants, }; use super::message_store::MessageStore; use enostr::Pubkey; use hashbrown::HashMap; -use nostrdb::{Ndb, Note, NoteKey, QueryResult, Subscription, Transaction}; +use nostrdb::{Ndb, Note, NoteKey, Subscription, Transaction}; use notedeck::{note::event_tag, NoteCache, NoteRef, UnknownIds}; pub struct ConversationCache { @@ -51,85 +51,6 @@ impl ConversationCache { self.conversations.get(&self.active?) } - /// A conversation is "opened" when the user navigates to the conversation - #[profiling::function] - pub fn open_conversation( - &mut self, - ndb: &Ndb, - txn: &Transaction, - id: ConversationId, - note_cache: &mut NoteCache, - unknown_ids: &mut UnknownIds, - selected: &Pubkey, - ) { - let Some(conversation) = self.conversations.get_mut(&id) else { - return; - }; - - let pubkeys = conversation.metadata.participants.clone(); - let participants: Vec<&[u8; 32]> = pubkeys.iter().map(|p| p.bytes()).collect(); - - // We should try and get more messages... this isn't ideal - let chatroom_filter = chatroom_filter(participants, selected); - - let mut updated = false; - { - profiling::scope!("chatroom_filter"); - let results = match ndb.query(txn, &chatroom_filter, 500) { - Ok(r) => r, - Err(e) => { - tracing::error!("problem with chatroom filter ndb::query: {e:?}"); - return; - } - }; - - for res in results { - let participants = get_participants(&res.note); - let parts = ParticipantSetUnowned::new(participants); - let cur_id = self - .registry - .get_or_insert(ConversationIdentifierUnowned::Nip17(parts)); - - if cur_id != id { - // this note isn't relevant to the current conversation, unfortunately... - continue; - } - - UnknownIds::update_from_note(txn, ndb, unknown_ids, note_cache, &res.note); - updated |= conversation.ingest_kind_14(res.note, res.note_key); - } - } - - if updated { - let latest = conversation.last_activity(); - refresh_order(&mut self.order, id, LatestMessage::Latest(latest)); - } - - self.active = Some(id); - tracing::info!("Set active to {id}"); - } - - #[profiling::function] - pub fn init_conversations( - &mut self, - ndb: &Ndb, - txn: &Transaction, - cur_acc: &Pubkey, - note_cache: &mut NoteCache, - unknown_ids: &mut UnknownIds, - ) { - let Some(results) = get_conversations(ndb, txn, cur_acc) else { - tracing::warn!("Got no conversations from ndb"); - return; - }; - - tracing::trace!("Received {} conversations from ndb", results.len()); - - for res in results { - self.ingest_chatroom_msg(res.note, res.note_key, ndb, txn, note_cache, unknown_ids); - } - } - #[profiling::function] pub fn ingest_chatroom_msg( &mut self, @@ -315,21 +236,6 @@ impl Default for ConversationCache { } } -#[profiling::function] -fn get_conversations<'a>( - ndb: &Ndb, - txn: &'a Transaction, - cur_acc: &Pubkey, -) -> Option<Vec<QueryResult<'a>>> { - match ndb.query(txn, &conversation_filter(cur_acc), 500) { - Ok(r) => Some(r), - Err(e) => { - tracing::error!("error fetching kind 14 messages: {e}"); - None - } - } -} - #[derive(Clone, Debug, Default)] pub struct ConversationMetadata { pub title: Option<TitleMetadata>,