From e0bf354bb6301761146d3025bdc6176c33877790 Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Sat, 4 Dec 2021 18:39:21 -0700 Subject: disambiguate pending vs fucked ETA --- src/lib.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index bb0fc76..74d4be9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,6 +13,8 @@ use web_sys::*; mod history; mod ocr; +use history::{History, NoETA}; + // When the `wee_alloc` feature is enabled, use `wee_alloc` as the global // allocator. #[cfg(feature = "wee_alloc")] @@ -110,7 +112,7 @@ async fn do_boot() { let document = gloo::utils::document(); - let history = Rc::new(RefCell::new(history::History::default())); + let history = Rc::new(RefCell::new(History::default())); let (manual_update_tx, manual_update_rx) = mpsc::channel::<()>(5); @@ -252,7 +254,7 @@ async fn do_boot() { history.record(queue_size); let estimated_finish = history.completion_time(); let eta_text = match estimated_finish { - Some(finish) => { + Ok(finish) => { let empty_array = js_sys::Array::new(); let options = { let kv_pair = js_sys::Array::new(); @@ -271,7 +273,10 @@ async fn do_boot() { format.call1(&JsValue::UNDEFINED, &finish).unwrap(); locale_string.as_string().unwrap() } - None => format!("pending"), + Err(NoETA::Pending) => format!("pending"), + Err(NoETA::Fuck) => { + format!("fucked (try reloading i guess?)") + } }; let label = format!(" - ETA {}", eta_text); eta.set_inner_text(&label); -- cgit v1.2.3