update ui
This commit is contained in:
@@ -14,8 +14,6 @@ pub enum Command {
|
||||
Relays(PublicKey),
|
||||
Njump(PublicKey),
|
||||
Trace(EventId),
|
||||
Speak(EventId),
|
||||
StopSpeaking,
|
||||
}
|
||||
|
||||
// Start or stop dictation in the focused composer
|
||||
|
||||
+11
-25
@@ -937,20 +937,6 @@ impl ChatPanel {
|
||||
Command::Trace(id) => {
|
||||
self.open_trace(id, window, cx);
|
||||
}
|
||||
Command::Speak(id) => {
|
||||
let text = self.message(id).map(|message| message.preview());
|
||||
|
||||
if let Some(text) = text
|
||||
&& let Err(e) = self.speaker.speak(&text)
|
||||
{
|
||||
window.push_notification(Notification::error(e.to_string()), cx);
|
||||
}
|
||||
}
|
||||
Command::StopSpeaking => {
|
||||
if let Err(error) = self.speaker.stop() {
|
||||
window.push_notification(Notification::error(error.to_string()), cx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1445,6 +1431,7 @@ impl ChatPanel {
|
||||
|
||||
let reply_id = *id;
|
||||
let dropdown_id = *id;
|
||||
let speech_id = *id;
|
||||
let public_key = *public_key;
|
||||
|
||||
let actions = actions.reply(cx.listener(move |this, _event, _window, cx| {
|
||||
@@ -1460,20 +1447,19 @@ impl ChatPanel {
|
||||
actions
|
||||
};
|
||||
|
||||
let speaking = self.speaker.speaking();
|
||||
let actions = actions.speech(cx.listener(move |this, _event, window, cx| {
|
||||
let text = this.message(&speech_id).map(|message| message.preview());
|
||||
|
||||
if let Some(text) = text
|
||||
&& let Err(error) = this.speaker.speak(&text)
|
||||
{
|
||||
window.push_notification(Notification::error(error.to_string()), cx);
|
||||
}
|
||||
}));
|
||||
|
||||
actions.dropdown(move |menu, _window, _cx| {
|
||||
let menu = menu
|
||||
.menu("Copy author", Box::new(Command::Copy(public_key)))
|
||||
menu.menu("Copy author", Box::new(Command::Copy(public_key)))
|
||||
.menu("Seen on", Box::new(Command::Trace(dropdown_id)))
|
||||
.separator()
|
||||
.menu("Read aloud", Box::new(Command::Speak(dropdown_id)));
|
||||
|
||||
if speaking {
|
||||
menu.menu("Stop speaking", Box::new(Command::StopSpeaking))
|
||||
} else {
|
||||
menu
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user