diff --git a/src/event.rs b/src/event.rs index b30ba33..140b776 100644 --- a/src/event.rs +++ b/src/event.rs @@ -5,7 +5,7 @@ pub enum Event { MinerStarted, MinerStopped { success: bool, full: bool }, KeyGeneratorStarted, - KeyGeneratorStopped { success: bool }, + KeyGeneratorStopped, KeyCreated { path: String, public: String, hash: String }, KeyLoaded { path: String, public: String, hash: String }, KeySaved { path: String, public: String, hash: String }, diff --git a/src/keys.rs b/src/keys.rs index 382661b..c64bd12 100644 --- a/src/keys.rs +++ b/src/keys.rs @@ -168,7 +168,6 @@ pub fn create_key(context: Arc>) { let miners_count = miners_count.clone(); thread::spawn(move || { miners_count.fetch_add(1, atomic::Ordering::SeqCst); - let mut success = false; match generate_key(KEYSTORE_DIFFICULTY, mining.clone()) { None => { debug!("Keystore mining finished"); @@ -180,12 +179,11 @@ pub fn create_key(context: Arc>) { info!("Key mined successfully: {:?}, hash: {}", &keystore.get_public(), &hash); context.bus.post(Event::KeyCreated { path: keystore.get_path().to_owned(), public: keystore.get_public().to_string(), hash }); context.set_keystore(Some(keystore)); - success = true; } } let miners = miners_count.fetch_sub(1, atomic::Ordering::SeqCst) - 1; if miners == 0 { - context.lock().unwrap().bus.post(Event::KeyGeneratorStopped { success }); + context.lock().unwrap().bus.post(Event::KeyGeneratorStopped); } }); } diff --git a/src/web_ui.rs b/src/web_ui.rs index ebeb5f1..360de98 100644 --- a/src/web_ui.rs +++ b/src/web_ui.rs @@ -192,7 +192,9 @@ fn action_loaded(context: &Arc>, web_view: &mut WebView<()>) { let eval = match e { Event::KeyCreated { path, public, hash } => { event_handle_luck(&handle, "Key successfully created! Don\\'t forget to save it!"); - format!("keystoreChanged('{}', '{}', '{}');", &path, &public, &hash) + let mut s = format!("keystoreChanged('{}', '{}', '{}');", &path, &public, &hash); + s.push_str(" showSuccess('You've got a new key! Don't forget to save it!')"); + s } Event::KeyLoaded { path, public, hash } | Event::KeySaved { path, public, hash } => { @@ -224,18 +226,13 @@ fn action_loaded(context: &Arc>, web_view: &mut WebView<()>) { } s } - Event::KeyGeneratorStopped {success} => { + Event::KeyGeneratorStopped => { status.mining = false; - let mut s = if status.syncing { + if status.syncing { String::from("setLeftStatusBarText('Syncing...'); showMiningIndicator(true, true);") } else { String::from("setLeftStatusBarText('Idle'); showMiningIndicator(false, false);") - }; - match success { - true => { s.push_str(" showSuccess('Key pair successfully mined!
Don`t forget to save!')"); } - false => { s.push_str(" showSuccess('Key mining got nothing, sorry.')"); } } - s } Event::Syncing { have, height } => { event_handle_info(&handle, "Syncing started...");