fix: Safely retrieve settings from LocalStorage
This commit is contained in:
1 file changed
+10
-2
@@ -81,9 +81,17 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (userSettings) {
|
if (userSettings) {
|
||||||
await settings.set(userSettings.ui);
|
settings.set(userSettings.ui);
|
||||||
} else {
|
} 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([
|
await Promise.all([
|
||||||
|
|||||||
Reference in new issue
Block a user