mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
use status bar to count receive events during listen
This commit is contained in:
parent
29fe24728c
commit
c3aa1f46cf
2 changed files with 13 additions and 10 deletions
|
|
@ -19,6 +19,10 @@
|
||||||
"en": "Logging in...",
|
"en": "Logging in...",
|
||||||
"en-tts": "Logging in..."
|
"en-tts": "Logging in..."
|
||||||
},
|
},
|
||||||
|
"mtxchat.busy.rx_events": {
|
||||||
|
"en": "Receiving events...",
|
||||||
|
"en-tts": "Receiving events..."
|
||||||
|
},
|
||||||
"mtxchat.busy.new_listen": {
|
"mtxchat.busy.new_listen": {
|
||||||
"en": "Syncing all events from server...",
|
"en": "Syncing all events from server...",
|
||||||
"en-tts": "Syncing all events from server..."
|
"en-tts": "Syncing all events from server..."
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
use crate::{get_username, web, MTX_LONG_TIMEOUT_MS};
|
use crate::{get_username, web, MTX_LONG_TIMEOUT_MS};
|
||||||
use chat::ChatOp;
|
use chat::ChatOp;
|
||||||
use modals::Modals;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tls::xtls::TlsConnector;
|
use tls::xtls::TlsConnector;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
use xous::CID;
|
use xous::CID;
|
||||||
use xous_ipc::Buffer;
|
use xous_ipc::Buffer;
|
||||||
|
use locales::t;
|
||||||
|
|
||||||
pub fn listen(
|
pub fn listen(
|
||||||
url: &mut Url,
|
url: &mut Url,
|
||||||
|
|
@ -16,8 +16,6 @@ pub fn listen(
|
||||||
dialogue_id: &str,
|
dialogue_id: &str,
|
||||||
chat_cid: CID,
|
chat_cid: CID,
|
||||||
) {
|
) {
|
||||||
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_MS);
|
log::info!("client_sync for {} ms...", MTX_LONG_TIMEOUT_MS);
|
||||||
|
|
||||||
let mut agent = ureq::builder()
|
let mut agent = ureq::builder()
|
||||||
|
|
@ -38,9 +36,8 @@ pub fn listen(
|
||||||
// TODO resolve suspected race condition
|
// TODO resolve suspected race condition
|
||||||
// This progress modal is masking a bug by slowing the loop down
|
// This progress modal is masking a bug by slowing the loop down
|
||||||
// Precursor "Guru Mediation" `voilated: nonNull::new_unchecked`
|
// Precursor "Guru Mediation" `voilated: nonNull::new_unchecked`
|
||||||
modals
|
chat::cf_set_status_text(chat_cid, t!("mtxchat.busy.rx_events", locales::LANG));
|
||||||
.start_progress("Receiving events ...", 0, events.len() as u32, 0)
|
chat::cf_set_busy_state(chat_cid, true);
|
||||||
.expect("no progress bar");
|
|
||||||
let mut event_count = 0;
|
let mut event_count = 0;
|
||||||
for event in events {
|
for event in events {
|
||||||
let sender = event.sender.unwrap_or("anon".to_string());
|
let sender = event.sender.unwrap_or("anon".to_string());
|
||||||
|
|
@ -58,12 +55,14 @@ pub fn listen(
|
||||||
}
|
}
|
||||||
.expect("failed to convert post into buffer");
|
.expect("failed to convert post into buffer");
|
||||||
event_count += 1;
|
event_count += 1;
|
||||||
modals
|
chat::cf_set_status_text(chat_cid,
|
||||||
.update_progress(event_count)
|
&format!("{} {}",
|
||||||
.expect("no progress update");
|
t!("mtxchat.busy.rx_events", locales::LANG),
|
||||||
|
event_count)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
modals.finish_progress().expect("failed progress finish");
|
chat::cf_set_busy_state(chat_cid, false);
|
||||||
// trigger the chat ui to save the dialogue to the pddb
|
// trigger the chat ui to save the dialogue to the pddb
|
||||||
xous::send_message(
|
xous::send_message(
|
||||||
chat_cid,
|
chat_cid,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue