Fixes issue where user prefs where not being updated correctly

This commit is contained in:
wess
2023-12-29 11:15:17 -05:00
parent bf2969614d
commit c986e2d203
2 changed files with 16 additions and 7 deletions
+1
View File
@@ -8,6 +8,7 @@ node_modules
.env
.env.*
!.env.example
pnpm-lock.yaml
.DS_STORE
.cache
@@ -9,13 +9,20 @@
import { onMount } from 'svelte';
import { user } from './store';
$: if (prefs) {
if (JSON.stringify(prefs) !== JSON.stringify(Object.entries($user.prefs))) {
if (!!prefs[prefs.length - 1][0] && !!prefs[prefs.length - 1][1]) {
arePrefsDisabled = false;
} else {
arePrefsDisabled = true;
}
$: if (prefs !== null) {
const prefString = JSON.stringify(prefs);
const userPrefString = JSON.stringify(Object.entries($user.prefs));
if (prefString !== userPrefString) {
const key = (prefs[prefs.length - 1][0] ?? '').trim();
const val = (prefs[prefs.length - 1][1] ?? '').trim();
if(prefs.length === 1) {
arePrefsDisabled = !((key.length === 0 && val.length === 0) || (key.length > 0 && val.length > 0));
} else {
arePrefsDisabled = !(key.length > 0 && val.length > 0);
}
} else {
arePrefsDisabled = true;
}
@@ -92,6 +99,7 @@
prefs.splice(index, 1);
prefs = prefs;
}
}}>
<span class="icon-x" aria-hidden="true" />
</Button>