Skip to content

Commit

Permalink
Fixed system tray bugs and fixed layout
Browse files Browse the repository at this point in the history
Used expect instead of unwrap
  • Loading branch information
JoshTheSnom authored and medzernik committed Feb 3, 2023
1 parent f88c3a8 commit 32b10c8
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,24 +154,24 @@ async fn main() {
let item_handle = app.tray_handle().get_item(&id);
match id.as_str() {
"hide_show" => {
let window = app.get_window("main").unwrap();
let window = app.get_window("main").expect("Couldn't fetch window");;

// you can also `set_selected`, `set_enabled` and `set_native_image` (macOS only).
match window.is_visible().unwrap() {
match window.is_visible().expect("Couldn't get window visibility") {
true => {
window.hide().unwrap();
item_handle.set_title("Show").unwrap()
window.hide().expect("Couldn't hide window");
item_handle.set_title("Show").expect("Couldn't change system tray item to show")
}
false => {
window.show().unwrap();
item_handle.set_title("Hide").unwrap()
window.show().expect("Couldn't show window");
item_handle.set_title("Hide").expect("Couldn't change system tray item to hide")
}
}

window.clone().on_window_event(move |window_event| {
if let WindowEvent::CloseRequested { .. } = window_event {
window.hide().unwrap();
item_handle.set_title("Show").unwrap();
window.hide().expect("Couldn't hide window");
item_handle.set_title("Show").expect("Couldn't change system tray item to show");
}
})
}
Expand Down

0 comments on commit 32b10c8

Please sign in to comment.