Local storage fallback

This commit is contained in:
2022-07-13 12:10:20 +02:00
parent ba0687af94
commit 0c88920f9e
2 changed files with 12 additions and 2 deletions

View File

@ -19,7 +19,17 @@ function createSettingsStore() {
s.set(val);
}
updateStorage(JSON.parse(window.localStorage.getItem('statusdash')));
const localStorageString = window.localStorage.getItem('statusdash');
let localStorage = {};
try {
localStorage = JSON.parse(localStorageString);
}
catch {
localStorage = {};
}
updateStorage(localStorage);
return {
subscribe: s.subscribe,