update ui

This commit is contained in:
2026-10-30 12:51:05 +07:00
parent 6ce20927ee
commit 905a339e3e
7 changed files with 56 additions and 73 deletions
+1 -3
View File
@@ -445,8 +445,7 @@ impl GroupPanel {
}
}
/// Track the keys rendered by this panel: members, message authors, and
/// activity subjects
/// Track the keys rendered by this panel.
fn track_participants(&mut self, cx: &mut Context<Self>) {
let Some(group) = self.group.upgrade() else {
return;
@@ -1060,7 +1059,6 @@ impl GroupPanel {
panel: cx.weak_entity(),
admin,
pinned,
speaking: self.speaker.speaking(),
persons: self.directory.clone(),
},
cx,
+13 -41
View File
@@ -16,8 +16,8 @@ use person::Directory;
use settings::AppSettings;
use state::NostrRegistry;
use ui::{
Avatar, MessageMedia, MessageRow, REACTION_EMOJIS, ReactionBar, ReplyPreview, group_reactions,
react_menu,
Avatar, MessageActions, MessageMedia, MessageRow, REACTION_EMOJIS, ReactionBar, ReplyPreview,
group_reactions, react_menu,
};
use crate::GroupPanel;
@@ -27,8 +27,6 @@ pub(crate) struct Actions {
pub panel: WeakEntity<GroupPanel>,
pub admin: bool,
pub pinned: bool,
/// Whether the panel's speaker is currently saying something
pub speaking: bool,
pub persons: Entity<Directory>,
}
@@ -90,9 +88,17 @@ pub(crate) fn render(
let admin = actions.admin;
let pinned = actions.pinned;
let group = actions.group;
let panel = actions.panel;
let speaking = actions.speaking;
let text = message.preview();
let speech_panel = actions.panel;
let panel = speech_panel.clone();
let speech_text = message.preview();
let row = row.overlay(MessageActions::new().speech(move |_event, _window, cx| {
_ = speech_panel.update_in(cx, |panel, window, cx| {
if let Err(error) = panel.speaker.speak(&speech_text) {
window.push_notification(Notification::error(error.to_string()), cx);
}
});
}));
let custom = nostr
.read(cx)
@@ -142,40 +148,6 @@ pub(crate) fn render(
}
});
let menu = menu.separator().item({
let panel = panel.clone();
let text = text.clone();
PopupMenuItem::new("Read aloud").on_click(move |_event, _window, cx| {
if let Err(error) = panel.update_in(cx, |panel, window, cx| {
if let Err(error) = panel.speaker.speak(&text) {
window.push_notification(Notification::error(error.to_string()), cx);
}
}) {
log::warn!("nip29: reading a message aloud failed: {error}");
}
})
});
let menu = if speaking {
menu.item({
let panel = panel.clone();
PopupMenuItem::new("Stop speaking").on_click(move |_event, _window, cx| {
if let Err(error) = panel.update_in(cx, |panel, window, cx| {
if let Err(error) = panel.speaker.stop() {
window
.push_notification(Notification::error(error.to_string()), cx);
}
}) {
log::warn!("nip29: stopping the speaker failed: {error}");
}
})
})
} else {
menu
};
if !admin {
return menu;
}