disable hotkeys if initial registration fails
This commit is contained in:
parent
2079f99d04
commit
1b749a857c
@ -82,7 +82,7 @@ async fn setup(app: &mut App) -> Result<(), Box<dyn Error>> {
|
|||||||
let pool = connect_db().await?;
|
let pool = connect_db().await?;
|
||||||
let mut setup_errors: Vec<String> = vec![];
|
let mut setup_errors: Vec<String> = vec![];
|
||||||
|
|
||||||
let conf = match AppConfig::load(&pool).await {
|
let mut conf = match AppConfig::load(&pool).await {
|
||||||
Ok(c) => c,
|
Ok(c) => c,
|
||||||
Err(SetupError::ConfigParseError(_)) => {
|
Err(SetupError::ConfigParseError(_)) => {
|
||||||
setup_errors.push(
|
setup_errors.push(
|
||||||
@ -100,8 +100,12 @@ async fn setup(app: &mut App) -> Result<(), Box<dyn Error>> {
|
|||||||
if let Err(_e) = config::set_auto_launch(conf.start_on_login) {
|
if let Err(_e) = config::set_auto_launch(conf.start_on_login) {
|
||||||
setup_errors.push("Error: Failed to manage autolaunch.".into());
|
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
|
// if session is empty, this is probably the first launch, so don't autohide
|
||||||
|
@ -33,6 +33,13 @@ pub struct HotkeysConfig {
|
|||||||
pub launch_terminal: Hotkey,
|
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)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
pub struct AppConfig {
|
pub struct AppConfig {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import { invoke } from '@tauri-apps/api/tauri';
|
import { invoke } from '@tauri-apps/api/tauri';
|
||||||
|
import { emit } from '@tauri-apps/api/event';
|
||||||
import { getRootCause } from '../lib/errors.js';
|
import { getRootCause } from '../lib/errors.js';
|
||||||
|
|
||||||
import { appState } from '../lib/state.js';
|
import { appState } from '../lib/state.js';
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
let error = null;
|
let error = null;
|
||||||
async function save() {
|
async function save() {
|
||||||
console.log('updating config');
|
|
||||||
try {
|
try {
|
||||||
await invoke('save_config', {config});
|
await invoke('save_config', {config});
|
||||||
$appState.config = await invoke('get_config');
|
$appState.config = await invoke('get_config');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user