This commit is contained in:
Fred Boniface
2023-07-07 11:29:33 +01:00
parent 7dc24646b9
commit c0997e92d4
25 changed files with 117 additions and 443 deletions

View File

@@ -8,9 +8,7 @@ function fromLocalStorage(storageKey, fallback) {
if (browser) {
const storedValue = localStorage.getItem(storageKey);
if (storedValue !== 'undefined' && storedValue !== null) {
return typeof fallback === 'object'
? JSON.parse(storedValue)
: storedValue;
return typeof fallback === 'object' ? JSON.parse(storedValue) : storedValue;
}
}
return fallback;
@@ -19,8 +17,7 @@ function fromLocalStorage(storageKey, fallback) {
function toLocalStorage(store, storageKey) {
if (browser) {
store.subscribe((value) => {
let storageValue =
typeof value === 'object' ? JSON.stringify(value) : value;
let storageValue = typeof value === 'object' ? JSON.stringify(value) : value;
localStorage.setItem(storageKey, storageValue);
});