Skip to content

Commit

Permalink
Add: network error toast
Browse files Browse the repository at this point in the history
  • Loading branch information
Zephira58 committed Sep 16, 2023
1 parent a8c001d commit 74ae32d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 23 deletions.
34 changes: 17 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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
}
},
Expand Down
Empty file removed src/tests.rs
Empty file.

0 comments on commit 74ae32d

Please sign in to comment.