handle errors on config update

This commit is contained in:
2023-04-28 14:33:23 -07:00
parent 70d71ce14e
commit c5dcc2e50a
5 changed files with 53 additions and 14 deletions

View File

@ -5,11 +5,18 @@
import Nav from '../ui/Nav.svelte';
import Link from '../ui/Link.svelte';
import ErrorAlert from '../ui/ErrorAlert.svelte';
// import Setting from '../ui/settings/Setting.svelte';
import { Setting, ToggleSetting, NumericSetting } from '../ui/settings';
let error = null;
async function save() {
await invoke('save_config', {config: $appState.config});
try {
await invoke('save_config', {config: $appState.config});
}
catch (e) {
error = e;
$appState.config = await invoke('get_config');
}
}
</script>
@ -57,3 +64,17 @@
</Setting>
</div>
{/await}
{#if error}
<div class="toast">
<div class="alert alert-error">
<div>
<span>{error}</span>
</div>
<div>
<button class="btn btn-sm btn-alert-error" on:click={() => error = null}>Ok</button>
</div>
</div>
</div>
{/if}