commit fdde0244e284fc8f8a061f67658bbe2b036c726f
parent 892d77d4e3f576bc9103398ba24f947d701fbb0d
Author: kernelkind <kernelkind@gmail.com>
Date: Fri, 24 Oct 2025 10:58:48 -0400
feat(reactions): use ProfileKey when possible for performance
Signed-off-by: kernelkind <kernelkind@gmail.com>
Diffstat:
4 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/crates/notedeck_columns/src/timeline/note_units.rs b/crates/notedeck_columns/src/timeline/note_units.rs
@@ -370,6 +370,7 @@ mod tests {
reaction: Reaction {
reaction: "+".to_owned(),
sender: self.random_sender(),
+ sender_profilekey: None,
},
}))
}
diff --git a/crates/notedeck_columns/src/timeline/timeline_units.rs b/crates/notedeck_columns/src/timeline/timeline_units.rs
@@ -169,6 +169,11 @@ fn to_reaction<'a>(
created_at: reacted_to_note.created_at(),
};
+ let sender_profilekey = ndb
+ .get_profile_by_pubkey(txn, payload.note.pubkey())
+ .ok()
+ .and_then(|p| p.key());
+
Some(ReactionResponse {
fragment: ReactionFragment {
noteref_reacted_to,
@@ -176,6 +181,7 @@ fn to_reaction<'a>(
reaction: Reaction {
reaction: reaction.to_string(),
sender: Pubkey::new(*payload.note.pubkey()),
+ sender_profilekey,
},
},
pk: payload.note.pubkey(),
diff --git a/crates/notedeck_columns/src/timeline/unit.rs b/crates/notedeck_columns/src/timeline/unit.rs
@@ -1,6 +1,7 @@
use std::collections::{BTreeMap, HashSet};
use enostr::Pubkey;
+use nostrdb::ProfileKey;
use notedeck::NoteRef;
use crate::timeline::note_units::{CompositeKey, CompositeType, UnitKey};
@@ -275,6 +276,7 @@ impl ReactionFragment {
pub struct Reaction {
pub reaction: String, // can't use char because some emojis are 'grapheme clusters'
pub sender: Pubkey,
+ pub sender_profilekey: Option<ProfileKey>,
}
/// Represents a singular repost
diff --git a/crates/notedeck_columns/src/ui/timeline.rs b/crates/notedeck_columns/src/ui/timeline.rs
@@ -711,13 +711,16 @@ fn render_reaction_cluster(
.reactions
.values()
.filter(|r| !mute.is_pk_muted(r.sender.bytes()))
- .map(|r| &r.sender)
- .map(|p| {
- profiling::scope!("ndb by pubkey");
- ProfileEntry {
- record: note_context.ndb.get_profile_by_pubkey(txn, p.bytes()).ok(),
- pk: p,
- }
+ .map(|r| (&r.sender, r.sender_profilekey))
+ .map(|(p, key)| {
+ let record = if let Some(key) = key {
+ profiling::scope!("ndb by key");
+ note_context.ndb.get_profile_by_key(txn, key).ok()
+ } else {
+ profiling::scope!("ndb by pubkey");
+ note_context.ndb.get_profile_by_pubkey(txn, p.bytes()).ok()
+ };
+ ProfileEntry { record, pk: p }
})
.collect()
};