Use match statement in msgbox function

Signed-off-by: Tomasz Boguszewski <tomekboguszewski1@gmail.com>
This commit is contained in:
Tomasz Boguszewski 2023-04-01 03:39:34 +02:00
parent e372c403a8
commit b542acff23

View File

@ -48,18 +48,24 @@ impl Interface for Session {
} }
fn msgbox(&self, msgtype: &str, title: &str, text: &str, link: &str) { fn msgbox(&self, msgtype: &str, title: &str, text: &str, link: &str) {
if msgtype == "input-password" { match msgtype {
self.sender "input-password" => {
.send(Data::Login((self.password.clone(), true))) self.sender
.ok(); .send(Data::Login((self.password.clone(), true)))
} else if msgtype == "re-input-password" { .ok();
log::error!("{}: {}", title, text); }
let pass = rpassword::prompt_password("Enter password: ").unwrap(); "re-input-password" => {
self.sender.send(Data::Login((pass, true))).ok(); log::error!("{}: {}", title, text);
} else if msgtype.contains("error") { let password = rpassword::prompt_password("Enter password: ").unwrap();
log::error!("{}: {}: {}", msgtype, title, text); let login_data = Data::Login((password, true));
} else { self.sender.send(login_data).ok();
log::info!("{}: {}: {}", msgtype, title, text); }
msg if msg.contains("error") => {
log::error!("{}: {}: {}", msgtype, title, text);
}
_ => {
log::info!("{}: {}: {}", msgtype, title, text);
}
} }
} }