diff --git a/libs/chat/locales/i18n.json b/libs/chat/locales/i18n.json index ede28f36f..bf1caf3a4 100644 --- a/libs/chat/locales/i18n.json +++ b/libs/chat/locales/i18n.json @@ -20,8 +20,8 @@ "en-tts": "no dialogues available to read" }, "chat.status.initial" : { - "en": "Idle", - "en-tts": "Idle" + "en": "Use ← to raise menu", + "en-tts": "Use ← to raise menu" }, "chat.help.navigation": { "en": "use ↑ & ↓ to scroll thru old posts\nuse ← & → to show menus\nF1-F4 dont do anything yet.", diff --git a/libs/chat/src/api.rs b/libs/chat/src/api.rs index 2a5765ce9..a41891705 100644 --- a/libs/chat/src/api.rs +++ b/libs/chat/src/api.rs @@ -43,7 +43,10 @@ pub enum ChatOp { /// Set the status idle text (to be shown when exiting all busy states) SetStatusIdleText, /// Update just the state of the busy animation, if any. Internal opcode. + /// Will skip the update if called too often. UpdateBusy, + /// Force update the busy bar, without rate throttling. Internal opcode. + UpdateBusyForced, /// exit the application Quit, } diff --git a/libs/chat/src/lib.rs b/libs/chat/src/lib.rs index 65bba49ec..52fc28563 100644 --- a/libs/chat/src/lib.rs +++ b/libs/chat/src/lib.rs @@ -363,6 +363,9 @@ pub fn server( Some(ChatOp::UpdateBusy) => { ui.redraw_busy().expect("CHAT couldn't redraw"); } + Some(ChatOp::UpdateBusyForced) => { + ui.redraw_status_forced().expect("CHAT couldn't redraw"); + } Some(ChatOp::SetStatusText) => { let buffer = unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) diff --git a/libs/chat/src/ui.rs b/libs/chat/src/ui.rs index ddb5bfc24..f564e425e 100644 --- a/libs/chat/src/ui.rs +++ b/libs/chat/src/ui.rs @@ -38,6 +38,8 @@ pub(crate) struct Ui { dialogue: Option, // Callbacks: + // callback to our own server + self_cid: CID, // optional SID of the "Owner" Chat App to receive UI-events app_cid: Option, // optional opcode ID to process UI-event msgs @@ -153,6 +155,7 @@ impl Ui { pddb_dict: None, pddb_key: None, dialogue: None, + self_cid: xous::connect(sid).unwrap(), app_cid, opcode_event, canvas, @@ -637,6 +640,15 @@ impl Ui { Ok(()) } + /// Update the status bar, without any throttling + pub(crate) fn redraw_status_forced(&mut self) -> Result<(), xous::Error> { + self.gam.post_textview(&mut self.status_tv)?; + self.gam.redraw().expect("couldn't redraw screen"); + let curtime = self.tt.elapsed_ms(); + self.status_last_update_ms = curtime; + Ok(()) + } + /// Returns `true` if the status bar is currently set for the busy animation pub(crate) fn is_busy(&self) -> bool { self.status_tv.busy_animation_state.is_some() @@ -646,7 +658,7 @@ impl Ui { pub(crate) fn set_status_text(&mut self, msg: &str) { self.status_tv.clear_str(); write!(self.status_tv, "{}", msg).ok(); - xous::send_message(self.app_cid.unwrap(), + xous::send_message(self.self_cid, xous::Message::new_scalar( ChatOp::UpdateBusy as usize, 0, 0, 0, 0) ).ok(); @@ -659,9 +671,10 @@ impl Ui { if self.status_tv.busy_animation_state.take().is_some() { self.status_tv.clear_str(); write!(self.status_tv, "{}", self.status_idle_text).ok(); - xous::send_message(self.app_cid.unwrap(), + // force the update, to ensure the idle state text is actually rendered + xous::send_message(self.self_cid, xous::Message::new_scalar( - ChatOp::UpdateBusy as usize, 0, 0, 0, 0) + ChatOp::UpdateBusyForced as usize, 0, 0, 0, 0) ).ok(); } }