add sigchat busy status text

This commit is contained in:
nworbnhoj 2023-12-11 06:21:07 +11:00
parent e5bb114c71
commit 2be426131c
2 changed files with 19 additions and 1 deletions

View file

@ -74,6 +74,10 @@
"en": "Signal online",
"en-tts": "Signal online"
},
"sigchat.status.probing": {
"en": "probing host for trusted tls",
"en-tts": "probing host for trusted tls"
},
"sigchat.wifi.connected": {
"en": "WiFi connected",
"en-tts": "WiFi connected",

View file

@ -172,16 +172,24 @@ impl<'a> SigChat<'a> {
/// true if at least 1 Certificate Authority is trusted
///
fn probe_host(&self, host: &str) -> bool {
self.chat
.set_status_text(t!("sigchat.status.probing", locales::LANG));
self.chat.set_busy_state(true);
let tls = Tls::new();
match tls.probe(host) {
Ok(0) => {
self.modals
.show_notification(t!("sigchat.account.abort", locales::LANG), None)
.expect("abort failed");
self.chat.set_busy_state(false);
false
}
Ok(_count) => true,
Ok(_count) => {
self.chat.set_busy_state(false);
true
}
Err(e) => {
self.chat.set_busy_state(false);
self.modals
.show_notification(&format!("{}", e), None)
.expect("qrcode failed");
@ -213,18 +221,24 @@ impl<'a> SigChat<'a> {
DEFAULT_DEVICE_NAME,
t!("sigchat.account.link.name", locales::LANG),
);
self.chat
.set_status_text(t!("sigchat.status.connecting", locales::LANG));
self.chat.set_busy_state(true);
match manager.link(Some(&name), Some(&host)) {
Ok(true) => {
log::info!("Linked Signal Account");
self.chat.set_busy_state(false);
}
Ok(false) => {
log::info!("failed to link Signal Account");
self.chat.set_busy_state(false);
}
Err(e) => {
log::warn!("error while linking Signal Account: {e}");
Account::delete(SIGCHAT_ACCOUNT).unwrap_or_else(|e| {
log::warn!("failed to delete unregistered account from pddb: {e}")
});
self.chat.set_busy_state(false);
self.modals
.show_notification(&format!("{}", e), None)
.expect("notification failed");