Add Sigchat.account_setup() option to abort (and read Chat Dialogue in pddb)

This commit is contained in:
nworbnhoj 2023-12-07 18:36:31 +11:00
parent b032a80a18
commit 0eb1838ada
2 changed files with 13 additions and 2 deletions

View file

@ -15,6 +15,10 @@
"en": "Please scan with primary Signal device",
"en-tts": "Please scan with primary Signal device"
},
"sigchat.account.offline": {
"en": "Read Signal offline",
"en-tts": "Read Signal offline"
},
"sigchat.account.register": {
"en": "Register a new Signal Account",
"en-tts": "Register a new Signal Account"

View file

@ -70,7 +70,8 @@ impl<'a> SigChat<'a> {
Ok(false)
}
/// Setup a Signal Account via Registration or Linking
/// Setup a Signal Account via Registration or Linking,
/// or abort setup and read existing chat Dialogues in pddb
///
fn account_setup(&mut self) -> Result<Account, Error> {
log::info!("Attempting to setup a Signal Account");
@ -80,6 +81,9 @@ impl<'a> SigChat<'a> {
self.modals
.add_list_item(t!("sigchat.account.register", locales::LANG))
.expect("failed add list item");
self.modals
.add_list_item(t!("sigchat.account.offline", locales::LANG))
.expect("failed add list item");
self.modals
.get_radiobutton(t!("sigchat.account.title", locales::LANG))
.expect("failed radiobutton modal");
@ -87,7 +91,10 @@ impl<'a> SigChat<'a> {
Ok(index) => match index {
0 => Ok(self.account_link()?),
1 => Ok(self.account_register()?),
2 => {
log::info!("account setup aborted");
Err(Error::new(ErrorKind::Other, "account setup aborted"))
}
_ => {
log::warn!("invalid index");
Err(Error::new(ErrorKind::Other, "invalid radio index"))