fix: Safely retrieve settings from LocalStorage

This commit is contained in:
kiosion 2024-08-24 20:34:39 -04:00
parent f568389235
commit f30428754f
No known key found for this signature in database
GPG Key ID: 8A2C67E22184F162
1 changed files with 10 additions and 2 deletions

View File

@ -81,9 +81,17 @@
});
if (userSettings) {
await settings.set(userSettings.ui);
settings.set(userSettings.ui);
} else {
await settings.set(JSON.parse(localStorage.getItem('settings') ?? '{}'));
let localStorageSettings = {} as Parameters<(typeof settings)['set']>[0];
try {
localStorageSettings = JSON.parse(localStorage.getItem('settings') ?? '{}');
} catch (e: unknown) {
console.error('Failed to parse settings from localStorage', e);
}
settings.set(localStorageSettings);
}
await Promise.all([