From 74ae32debb992577c458662b3f672cd567713b3d Mon Sep 17 00:00:00 2001 From: Aviion Gibbs Date: Sat, 16 Sep 2023 16:16:28 +0930 Subject: [PATCH] Add: network error toast --- Cargo.lock | 34 +++++++++++++++++----------------- src/main.rs | 11 +++++------ src/tests.rs | 0 3 files changed, 22 insertions(+), 23 deletions(-) delete mode 100644 src/tests.rs diff --git a/Cargo.lock b/Cargo.lock index 792d24a..756f426 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -310,7 +310,7 @@ checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.35", ] [[package]] @@ -353,7 +353,7 @@ checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.35", ] [[package]] @@ -530,7 +530,7 @@ checksum = "965ab7eb5f8f97d2a083c799f3a1b994fc397b2fe2da5d1da1626ce15a39f2b1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.35", ] [[package]] @@ -1012,7 +1012,7 @@ checksum = "f95e2801cd355d4a1a3e3953ce6ee5ae9603a5c833455343a8bfe3f44d418246" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.35", ] [[package]] @@ -2106,7 +2106,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.35", ] [[package]] @@ -2208,7 +2208,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.35", ] [[package]] @@ -2354,7 +2354,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.35", ] [[package]] @@ -2385,7 +2385,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.35", ] [[package]] @@ -2817,7 +2817,7 @@ checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.35", ] [[package]] @@ -2839,7 +2839,7 @@ checksum = "8725e1dfadb3a50f7e5ce0b1a540466f6ed3fe7a0fca2ac2b8b831d31316bd00" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.35", ] [[package]] @@ -3262,9 +3262,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.33" +version = "2.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9caece70c63bfba29ec2fed841a09851b14a235c60010fa4de58089b6c025668" +checksum = "59bf04c28bee9043ed9ea1e41afc0552288d3aba9c6efdd78903b802926f4879" dependencies = [ "proc-macro2", "quote", @@ -3301,7 +3301,7 @@ checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.35", ] [[package]] @@ -3371,7 +3371,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.35", ] [[package]] @@ -3451,7 +3451,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.35", ] [[package]] @@ -3642,7 +3642,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.35", "wasm-bindgen-shared", ] @@ -3676,7 +3676,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.35", "wasm-bindgen-backend", "wasm-bindgen-shared", ] diff --git a/src/main.rs b/src/main.rs index 6930e52..8d9b1d2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -103,7 +103,7 @@ impl eframe::App for MyApp { let result = tokio::runtime::Runtime::new() .unwrap() .block_on(is_server_alive(ip, port as u16, 30)); - tx.send(dbg!(result)).expect("Failed to send result"); + tx.send(result).expect("Failed to send result"); }); if let Ok(result) = self.rx.try_recv() { @@ -113,19 +113,18 @@ impl eframe::App for MyApp { println!("Network Connection Established"); self.network_status = NetworkStatus::Up } else { - self.toasts.dismiss_all_toasts(); - cb(self.toasts.error("Network Connection Failed!!")); - println!("Network Connection Failed!"); self.network_status = NetworkStatus::Down } } } NetworkStatus::Down => { ui.colored_label(Color32::from_rgb(150, 0, 0), "Warning: Was not able to successfully test your network connection, you may have difficulties.\n\nPlease ensure that you have a stable network connection\n"); + let bypass = ui.button("Bypass").clicked(); - self.toasts.dismiss_all_toasts(); - cb(self.toasts.warning("Network connection could not be established!")); if bypass { + self.toasts.dismiss_all_toasts(); + cb(self.toasts.warning("Connection couldn't be verified!")); + self.network_status = NetworkStatus::Up } }, diff --git a/src/tests.rs b/src/tests.rs deleted file mode 100644 index e69de29..0000000