track message sender's emojis instead of global registry

This commit is contained in:
2026-10-12 17:39:43 +07:00
parent d092666404
commit f87bed75bf
11 changed files with 205 additions and 541 deletions
+20 -5
View File
@@ -532,11 +532,11 @@ impl GroupPanel {
}
let replies: Vec<EventId> = self.reply_to.take().into_iter().collect();
let emojis = self.emoji_tags(&content, cx);
let Ok(send) = self
.group
.update(cx, |group, cx| group.send_message(&content, replies, cx))
else {
let Ok(send) = self.group.update(cx, |group, cx| {
group.send_message(&content, replies, emojis, cx)
}) else {
return;
};
@@ -613,6 +613,18 @@ impl GroupPanel {
.and_then(|group| Notice::of(group.read(cx)))
}
/// The signed-in user's custom emoji tags referenced in `content`
fn emoji_tags(&self, content: &str, cx: &App) -> Vec<Tag> {
let Some(current_user) = NostrRegistry::global(cx).read(cx).current_user() else {
return Vec::new();
};
self.directory
.read(cx)
.person(&current_user, cx)
.emoji_tags(content)
}
fn react(
&mut self,
group: WeakEntity<Group>,
@@ -621,7 +633,10 @@ impl GroupPanel {
window: &mut Window,
cx: &mut Context<Self>,
) {
let Ok(react) = group.update(cx, |group, cx| group.send_reaction(id, emoji, cx)) else {
let emojis = self.emoji_tags(&emoji, cx);
let Ok(react) = group.update(cx, |group, cx| group.send_reaction(id, emoji, emojis, cx))
else {
return;
};
+17 -2
View File
@@ -7,7 +7,7 @@ use gpui::{
};
use nip29::{Activity, Group, Reaction};
use nostr_sdk::prelude::{EventId, Kind};
use person::{Directory, PersonRegistry};
use person::Directory;
use settings::AppSettings;
use state::NostrRegistry;
use theme::{ActiveTheme, TextStyle, Typeset as _};
@@ -164,7 +164,22 @@ fn react_menu(
)
});
let emojis = PersonRegistry::current_emojis(cx);
let emojis = panel
.upgrade()
.and_then(|panel| {
let current_user = NostrRegistry::global(cx).read(cx).current_user()?;
Some(
panel
.read(cx)
.directory
.read(cx)
.person(&current_user, cx)
.emojis()
.to_vec(),
)
})
.unwrap_or_default();
if emojis.is_empty() {
return menu;
}