diff --git a/src-tauri/src/app.rs b/src-tauri/src/app.rs index aeff75f..7b53eea 100644 --- a/src-tauri/src/app.rs +++ b/src-tauri/src/app.rs @@ -82,7 +82,7 @@ async fn setup(app: &mut App) -> Result<(), Box> { let pool = connect_db().await?; let mut setup_errors: Vec = vec![]; - let conf = match AppConfig::load(&pool).await { + let mut conf = match AppConfig::load(&pool).await { Ok(c) => c, Err(SetupError::ConfigParseError(_)) => { setup_errors.push( @@ -100,8 +100,12 @@ async fn setup(app: &mut App) -> Result<(), Box> { if let Err(_e) = config::set_auto_launch(conf.start_on_login) { setup_errors.push("Error: Failed to manage autolaunch.".into()); } - if let Err(e) = shortcuts::register_hotkeys(&conf.hotkeys) { - setup_errors.push(format!("{e}")); + + // if hotkeys fail to register, disable them so that this error doesn't have to keep showing up + if let Err(_e) = shortcuts::register_hotkeys(&conf.hotkeys) { + conf.hotkeys.disable_all(); + conf.save(&pool).await?; + setup_errors.push("Failed to register hotkeys. Hotkey settings have been disabled.".into()); } // if session is empty, this is probably the first launch, so don't autohide diff --git a/src-tauri/src/config.rs b/src-tauri/src/config.rs index 4a9537e..5cfb352 100644 --- a/src-tauri/src/config.rs +++ b/src-tauri/src/config.rs @@ -33,6 +33,13 @@ pub struct HotkeysConfig { pub launch_terminal: Hotkey, } +impl HotkeysConfig { + pub fn disable_all(&mut self) { + self.show_window.enabled = false; + self.launch_terminal.enabled = false; + } +} + #[derive(Clone, Debug, Serialize, Deserialize)] pub struct AppConfig { diff --git a/src/views/EnterCredentials.svelte b/src/views/EnterCredentials.svelte index 2570a8b..4a61004 100644 --- a/src/views/EnterCredentials.svelte +++ b/src/views/EnterCredentials.svelte @@ -1,6 +1,7 @@