diff --git a/apps/mtxchat/locales/i18n.json b/apps/mtxchat/locales/i18n.json index 53ba2621a..d5d3edfea 100644 --- a/apps/mtxchat/locales/i18n.json +++ b/apps/mtxchat/locales/i18n.json @@ -241,6 +241,10 @@ "ja": "WiFi not connected. Entering read-only mode *EN*", "zh": "WiFi not connected. Entering read-only mode *EN*" }, + "mtxchat.wifi.warning_status": { + "en": "No connection! Read-only.", + "en-tts": "No connection! Read-only." + }, "mtxchat.listen.patience": { "en": "It takes a while to get new events from the [matrix] server.\nPlease be patient :-)", "en-tts": "It takes a while to get new events from the [matrix] server.\nPlease be patient." diff --git a/apps/mtxchat/src/lib.rs b/apps/mtxchat/src/lib.rs index 35e18b256..3bf47b132 100644 --- a/apps/mtxchat/src/lib.rs +++ b/apps/mtxchat/src/lib.rs @@ -9,6 +9,7 @@ use listen::listen; use locales::t; use modals::Modals; use pddb::Pddb; +use ticktimer_server::Ticktimer; use std::fmt::Write as _; use std::io::{Error, ErrorKind, Read, Write as StdWrite}; use std::sync::Arc; @@ -35,8 +36,8 @@ const USER_DOMAIN_KEY: &str = "user_domain"; const DOMAIN_MATRIX: &str = "matrix.org"; -const MTX_LONG_TIMEOUT: i32 = 60000; // ms -const WIFI_TIMEOUT: u32 = 10; // seconds +const MTX_LONG_TIMEOUT_MS: i32 = 60000; // ms +const WIFI_TIMEOUT_MS: u32 = 30_000; // ms pub const CLOCK_NOT_SET_ID: usize = 1; pub const PDDB_NOT_MOUNTED_ID: usize = 2; @@ -84,6 +85,7 @@ pub struct MtxChat<'a> { new_username: bool, new_room: bool, status: String, + tt: Ticktimer, } impl<'a> MtxChat<'a> { pub fn new(chat: &Chat) -> MtxChat { @@ -117,6 +119,7 @@ impl<'a> MtxChat<'a> { new_username: false, new_room: false, status, + tt: ticktimer_server::Ticktimer::new().unwrap(), } } @@ -674,25 +677,23 @@ impl<'a> MtxChat<'a> { while self.wifi_try_modal() { self.netmgr.connection_manager_wifi_on_and_run().unwrap(); - self.modals - .start_progress("Connecting ...", 0, 10, 0) - .expect("no progress bar"); - let tt = ticktimer_server::Ticktimer::new().unwrap(); - for wait in 0..WIFI_TIMEOUT { - tt.sleep_ms(1000).unwrap(); - self.modals - .update_progress(wait) - .expect("no progress update"); + self.chat.set_status_text(t!("mtxchat.busy.connecting", locales::LANG)); + self.chat.set_busy_state(true); + let start = self.tt.elapsed_ms(); + while self.tt.elapsed_ms() - start < WIFI_TIMEOUT_MS as u64 { if let Some(conf) = self.netmgr.get_ipv4_config() { if conf.dhcp == com_rs::DhcpState::Bound { - self.modals - .finish_progress() - .expect("failed progress finish"); + self.chat.set_busy_state(false); + self.chat.set_status_text(&self.status); return true; } } + self.tt.sleep_ms(1000).unwrap(); } + self.modals.show_notification(t!("mtxchat.wifi.warning", locales::LANG), None).unwrap(); } + self.chat.set_busy_state(false); + self.chat.set_status_text(t!("mtxchat.wifi.warning_status", locales::LANG)); false } diff --git a/apps/mtxchat/src/listen.rs b/apps/mtxchat/src/listen.rs index 51bb325cf..c885d2438 100644 --- a/apps/mtxchat/src/listen.rs +++ b/apps/mtxchat/src/listen.rs @@ -1,4 +1,4 @@ -use crate::{get_username, web, MTX_LONG_TIMEOUT}; +use crate::{get_username, web, MTX_LONG_TIMEOUT_MS}; use chat::ChatOp; use modals::Modals; use std::sync::Arc; @@ -18,7 +18,7 @@ pub fn listen( ) { let xns = xous_names::XousNames::new().unwrap(); let modals = Modals::new(&xns).expect("can't connect to Modals server"); - log::info!("client_sync for {} ms...", MTX_LONG_TIMEOUT); + log::info!("client_sync for {} ms...", MTX_LONG_TIMEOUT_MS); let mut agent = ureq::builder() .tls_connector(Arc::new(TlsConnector{})) @@ -27,7 +27,7 @@ pub fn listen( url, filter, since, - MTX_LONG_TIMEOUT, + MTX_LONG_TIMEOUT_MS, &room_id, &token, &mut agent, diff --git a/libs/chat/src/ui.rs b/libs/chat/src/ui.rs index 4cd883036..6a822823e 100644 --- a/libs/chat/src/ui.rs +++ b/libs/chat/src/ui.rs @@ -21,7 +21,7 @@ use xous::{MessageEnvelope, CID}; use xous_names::XousNames; -pub const BUSY_ANIMATION_RATE_MS: usize = 50; +pub const BUSY_ANIMATION_RATE_MS: usize = 200; #[allow(dead_code)] pub(crate) struct Ui { @@ -627,6 +627,7 @@ impl Ui { pub(crate) fn redraw_busy(&mut self) -> Result<(), xous::Error> { let curtime = self.tt.elapsed_ms(); if curtime - self.status_last_update_ms > BUSY_ANIMATION_RATE_MS as u64 { + log::info!("update!"); self.gam.post_textview(&mut self.status_tv)?; self.gam.redraw().expect("couldn't redraw screen"); self.status_last_update_ms = curtime; diff --git a/services/gam/src/lib.rs b/services/gam/src/lib.rs index 9e351624c..550f68e8f 100644 --- a/services/gam/src/lib.rs +++ b/services/gam/src/lib.rs @@ -154,6 +154,7 @@ impl Gam { tv.bounds_computed = tvr.bounds_computed; tv.cursor = tvr.cursor; tv.overflow = tvr.overflow; + tv.busy_animation_state = tvr.busy_animation_state; } api::Return::NotCurrentlyDrawable => { tv.bounds_computed = None;