diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 6b6f9ba..9e0fc5e 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -18,6 +18,7 @@ fn main() { }, Some(("get", m)) => cli::get(m), Some(("exec", m)) => cli::exec(m), + Some(("shortcut", m)) => cli::invoke_shortcut(m), _ => unreachable!(), }; diff --git a/src-tauri/src/server/server_win.rs b/src-tauri/src/server/server_win.rs index 4b25106..07dd7ca 100644 --- a/src-tauri/src/server/server_win.rs +++ b/src-tauri/src/server/server_win.rs @@ -6,12 +6,11 @@ use tokio::{ sync::oneshot, }; -#[cfg(windows)] use windows::Win32:: { Foundation::HANDLE, System::Pipes::GetNamedPipeClientProcessId, }; -#[cfg(windows)] + use std::os::windows::io::AsRawHandle; use tauri::async_runtime as rt; diff --git a/src/ui/settings/NumericSetting.svelte b/src/ui/settings/NumericSetting.svelte index 4c8e4c2..b4a34cd 100644 --- a/src/ui/settings/NumericSetting.svelte +++ b/src/ui/settings/NumericSetting.svelte @@ -10,15 +10,21 @@ export let min = null; export let max = null; export let decimal = false; + export let debounceInterval = 0; const dispatch = createEventDispatcher(); $: localValue = value.toString(); let lastInputTime = null; function debounce(event) { - lastInputTime = Date.now(); localValue = localValue.replace(/[^-0-9.]/g, ''); + if (debounceInterval === 0) { + updateValue(localValue); + return; + } + + lastInputTime = Date.now(); const eventTime = lastInputTime; const pendingValue = localValue; window.setTimeout( @@ -28,7 +34,7 @@ updateValue(pendingValue); } }, - 500 + debounceInterval, ) } diff --git a/src/views/Settings.svelte b/src/views/Settings.svelte index aaea8bf..affdaaf 100644 --- a/src/views/Settings.svelte +++ b/src/views/Settings.svelte @@ -14,15 +14,19 @@ import { backInOut } from 'svelte/easing'; + // make an independent copy so it can differ from the main config object + let config = JSON.parse(JSON.stringify($appState.config)); + $: configModified = JSON.stringify(config) !== JSON.stringify($appState.config); + let error = null; async function save() { console.log('updating config'); try { - await invoke('save_config', {config: $appState.config}); + await invoke('save_config', {config}); + $appState.config = await invoke('get_config'); } catch (e) { error = e; - $appState.config = await invoke('get_config'); } } @@ -35,62 +39,60 @@

Settings

-{#await invoke('get_config') then config} -
- - - - Start Creddy when you log in to your computer. - - +
+ + + + Start Creddy when you log in to your computer. + + - - - Minimize to the system tray at startup. - - + + + Minimize to the system tray at startup. + + - - - How long to wait after a request is approved/denied before minimizing - the window to tray. Only applicable if the window was minimized - to tray before the request was received. - - + + + How long to wait after a request is approved/denied before minimizing + the window to tray. Only applicable if the window was minimized + to tray before the request was received. + + - - - - - - Update or re-enter your encrypted credentials. - - + + + + + + Update or re-enter your encrypted credentials. + + - - - Choose your preferred terminal emulator (e.g. gnome-terminal or wt.exe.) May be an absolute path or an executable discoverable on $PATH. - - - + + + Choose your preferred terminal emulator (e.g. gnome-terminal or wt.exe.) May be an absolute path or an executable discoverable on $PATH. + + + - -
-

Click on a keybinding to modify it. Use the checkbox to enable or disable a keybinding entirely.

+ +
+

Click on a keybinding to modify it. Use the checkbox to enable or disable a keybinding entirely.

-
- - -
+
+ +
- +
+
-
-{/await} +
{#if error}
@@ -104,4 +106,15 @@
+{:else if configModified} +
+
+ You have unsaved changes. + +
+ + Save +
+
+
{/if}