diff --git a/Cargo.toml b/Cargo.toml index 5c41406..c23c9d3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,6 +20,7 @@ relm4 = { version = "0.5", features = ["macros", "libadwaita"] } gtk = { package = "gtk4", version = "0.5", features = ["v4_8"] } adw = { package = "libadwaita", version = "0.2", features = ["v1_2"] } rfd = { version = "0.11", features = ["xdg-portal"], default-features = false } +open = "3.2.0" anime-launcher-sdk = { path = "anime-launcher-sdk" } @@ -34,5 +35,3 @@ anyhow = "1.0" cached = { version = "0.42", features = ["proc_macro"] } serde_json = "1" md-5 = { version = "0.10", features = ["asm"] } - -open = "3.2.0" diff --git a/src/ui/first_run/main.rs b/src/ui/first_run/main.rs index cfb9ff2..dd5e083 100644 --- a/src/ui/first_run/main.rs +++ b/src/ui/first_run/main.rs @@ -206,11 +206,9 @@ impl SimpleComponent for FirstRunApp { dialog.set_response_appearance("save", adw::ResponseAppearance::Suggested); - #[allow(unused_must_use)] dialog.connect_response(Some("save"), |_, _| { - match open::that(crate::DEBUG_FILE.as_os_str()) { - Ok(()) => {}, - Err(err) => tracing::error!("Failed to open debug file: {}", err) + if let Err(err) = open::that(crate::DEBUG_FILE.as_os_str()) { + tracing::error!("Failed to open debug file: {err}"); } }); diff --git a/src/ui/main.rs b/src/ui/main.rs index 8e5e20c..0940b99 100644 --- a/src/ui/main.rs +++ b/src/ui/main.rs @@ -24,8 +24,6 @@ use crate::ui::components::*; use super::preferences::main::*; use super::about::*; -use open::*; - relm4::new_action_group!(WindowActionGroup, "win"); relm4::new_stateless_action!(LauncherFolder, WindowActionGroup, "launcher_folder"); @@ -528,56 +526,48 @@ impl SimpleComponent for App { // TODO: reduce code somehow group.add_action::(&RelmAction::new_stateless(clone!(@strong sender => move |_| { - match open::that(LAUNCHER_FOLDER.as_path()) { - Ok(()) => {}, - Err(err) => { - sender.input(AppMsg::Toast { - title: tr("launcher-folder-opening-error"), - description: Some(err.to_string()) - }); - tracing::error!("Failed to open launcher folder: {err}"); - } + if let Err(err) = open::that(LAUNCHER_FOLDER.as_path()) { + sender.input(AppMsg::Toast { + title: tr("launcher-folder-opening-error"), + description: Some(err.to_string()) + }); + + tracing::error!("Failed to open launcher folder: {err}"); } }))); group.add_action::(&RelmAction::new_stateless(clone!(@strong sender => move |_| { - match open::that(&CONFIG.game.path) { - Ok(()) => {}, - Err(err) => { - sender.input(AppMsg::Toast { - title: tr("game-folder-opening-error"), - description: Some(err.to_string()) - }); - tracing::error!("Failed to open game folder: {err}"); - } + if let Err(err) = open::that(&CONFIG.game.path) { + sender.input(AppMsg::Toast { + title: tr("game-folder-opening-error"), + description: Some(err.to_string()) + }); + + tracing::error!("Failed to open game folder: {err}"); } }))); group.add_action::(&RelmAction::new_stateless(clone!(@strong sender => move |_| { if let Some(file) = anime_launcher_sdk::consts::config_file() { - match open::that(file) { - Ok(()) => {}, - Err(err) => { - sender.input(AppMsg::Toast { - title: tr("config-file-opening-error"), - description: Some(err.to_string()) - }); - tracing::error!("Failed to open config file: {err}"); - } + if let Err(err) = open::that(file) { + sender.input(AppMsg::Toast { + title: tr("config-file-opening-error"), + description: Some(err.to_string()) + }); + + tracing::error!("Failed to open config file: {err}"); } } }))); group.add_action::(&RelmAction::new_stateless(clone!(@strong sender => move |_| { - match open::that(crate::DEBUG_FILE.as_os_str()) { - Ok(()) => {}, - Err(err) => { - sender.input(AppMsg::Toast { - title: tr("debug-file-opening-error"), - description: Some(err.to_string()) - }); - tracing::error!("Failed to open debug file: {err}"); - } + if let Err(err) = open::that(crate::DEBUG_FILE.as_os_str()) { + sender.input(AppMsg::Toast { + title: tr("debug-file-opening-error"), + description: Some(err.to_string()) + }); + + tracing::error!("Failed to open debug file: {err}"); } }))); @@ -1275,11 +1265,9 @@ impl App { dialog.set_response_appearance("save", adw::ResponseAppearance::Suggested); - #[allow(unused_must_use)] dialog.connect_response(Some("save"), |_, _| { - match open::that(crate::DEBUG_FILE.as_os_str()) { - Ok(()) => {}, - Err(err) => tracing::error!("Failed to open debug file: {}", err), + if let Err(err) = open::that(crate::DEBUG_FILE.as_os_str()) { + tracing::error!("Failed to open debug file: {err}"); } }); diff --git a/src/ui/preferences/main.rs b/src/ui/preferences/main.rs index 3940aba..1eef4fc 100644 --- a/src/ui/preferences/main.rs +++ b/src/ui/preferences/main.rs @@ -164,11 +164,9 @@ impl SimpleAsyncComponent for PreferencesApp { dialog.set_response_appearance("save", adw::ResponseAppearance::Suggested); - #[allow(unused_must_use)] dialog.connect_response(Some("save"), |_, _| { - match open::that(crate::DEBUG_FILE.as_os_str()) { - Ok(()) => {}, - Err(err) => tracing::error!("Failed to open debug file: {}", err) + if let Err(err) = open::that(crate::DEBUG_FILE.as_os_str()) { + tracing::error!("Failed to open debug file: {err}"); } });