Added more convenient cooldown time formatting.

This commit is contained in:
Revertron
2021-05-09 18:44:09 +02:00
parent a5311de626
commit 6da89bcf0d
+13 -2
View File
@@ -423,13 +423,24 @@ fn action_create_domain(context: Arc<Mutex<Context>>, miner: Arc<Mutex<Miner>>,
let _ = web_view.eval("domainMiningUnavailable();");
}
MineResult::Cooldown { time } => {
event_info(web_view, &format!("You have cooldown, just {} more minutes!", time / 60));
show_warning(web_view, &format!("You have cooldown, just {} more minutes!", time / 60));
event_info(web_view, &format!("You have cooldown {}!", format_cooldown(time)));
show_warning(web_view, &format!("You have cooldown {}!", format_cooldown(time)));
let _ = web_view.eval("domainMiningUnavailable();");
}
}
}
fn format_cooldown(time: i64) -> String {
if time <= 60 {
return format!("{} seconds", time);
}
let minutes = time / 60;
if minutes <= 60 {
return format!("{} minutes", minutes);
}
format!("{} hours", minutes / 60)
}
fn show_warning(web_view: &mut WebView<()>, text: &str) {
let str = text.replace('\'', "\\'");
match web_view.eval(&format!("showWarning('{}');", &str)) {