rework error alerts
This commit is contained in:
@ -17,34 +17,22 @@
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
let errorMsg = null;
|
||||
let alert;
|
||||
let passphrase = '';
|
||||
|
||||
let saving = false;
|
||||
async function unlock() {
|
||||
saving = true;
|
||||
try {
|
||||
saving = true;
|
||||
let r = await invoke('unlock', {passphrase});
|
||||
await alert.run(async () => invoke('unlock', {passphrase}));
|
||||
$appState.sessionStatus = 'unlocked';
|
||||
emit('unlocked');
|
||||
dispatch('unlocked');
|
||||
}
|
||||
catch (e) {
|
||||
const root = getRootCause(e);
|
||||
if (e.code === 'GetSession' && root.code) {
|
||||
errorMsg = `Error response from AWS (${root.code}): ${root.msg}`;
|
||||
}
|
||||
else {
|
||||
errorMsg = e.msg;
|
||||
}
|
||||
|
||||
// if the alert already existed, shake it
|
||||
if (alert) {
|
||||
alert.shake();
|
||||
}
|
||||
|
||||
finally {
|
||||
saving = false;
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -61,9 +49,7 @@
|
||||
<label class="space-y-4">
|
||||
<h2 class="font-bold text-xl text-center">Please enter your passphrase</h2>
|
||||
|
||||
{#if errorMsg}
|
||||
<ErrorAlert bind:this="{alert}">{errorMsg}</ErrorAlert>
|
||||
{/if}
|
||||
<ErrorAlert bind:this="{alert}" />
|
||||
|
||||
<!-- svelte-ignore a11y-autofocus -->
|
||||
<PassphraseInput autofocus="true" bind:value={passphrase} placeholder="correct horse battery staple" />
|
||||
|
Reference in New Issue
Block a user