diff --git a/src/web_ui.rs b/src/web_ui.rs index 2c14f9b..f70567b 100644 --- a/src/web_ui.rs +++ b/src/web_ui.rs @@ -423,13 +423,24 @@ fn action_create_domain(context: Arc>, miner: Arc>, 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)) {