try to lay in some hooks for how to interact with the busy API

this is just an example, want to get this up for review before
debugging all the problems
This commit is contained in:
bunnie 2023-10-20 00:50:29 +08:00
parent be39c44b17
commit 4142549804
2 changed files with 20 additions and 2 deletions

View file

@ -1,4 +1,16 @@
{
"mtxchat.busy.connecting": {
"en": "Connecting...",
"en-tts": "Connecting..."
},
"mtxchat.busy.updating": {
"en": "Updating...",
"en-tts": "Updating..."
},
"mtxchat.busy.sending": {
"en": "Sending...",
"en-tts": "Sending..."
},
"mtxchat.clock.warning": {
"en": "WARNING: clock not set",
"en-tts": "WARNING: clock not set",

View file

@ -241,6 +241,7 @@ impl<'a> MtxChat<'a> {
pub fn connect(&mut self) -> bool {
log::info!("Attempting connect to Matrix server");
self.chat.set_busy_state(Some(t!("mtxchat.busy.connecting", locales::LANG).to_owned())).expect("couldn't set busy state");
if self.wifi() {
if self.login() {
if let Some(_room_id) = self.get_room_id() {
@ -252,6 +253,7 @@ impl<'a> MtxChat<'a> {
.show_notification(t!("mtxchat.listen.patience", locales::LANG), None)
.expect("notification failed");
}
self.chat.set_busy_state(None).expect("couldn't clear busy state");
return true;
} else {
self.modals
@ -273,6 +275,7 @@ impl<'a> MtxChat<'a> {
.expect("notification failed");
}
self.dialogue_set(None);
self.chat.set_busy_state(None).expect("couldn't clear busy state");
false
}
@ -626,14 +629,17 @@ impl<'a> MtxChat<'a> {
&self.room_id,
) {
(true, Some(token), Some(user_domain), Some(room_id)) => {
self.chat.set_busy_state(Some(t!("mtxchat.busy.sending", locales::LANG).to_owned())).expect("couldn't set busy state");
log::info!("txn_id = {}", txn_id);
let mut url = Url::parse("https://matrix.org").unwrap();
url.set_host(Some(user_domain)).expect("failed to set host");
if web::send_message(&mut url, &room_id, &text, &txn_id, token, &mut self.agent) {
let r = if web::send_message(&mut url, &room_id, &text, &txn_id, token, &mut self.agent) {
"SENT"
} else {
"FAILED TO SEND"
}
};
self.chat.set_busy_state(None).expect("couldn't clear busy state");
r
}
(false, _, _, _) => "Not logged in",
(_, None, _, _) => "No token set",