Skip to content

Commit

Permalink
Fix theme color have null value when there is no theme set on the loc…
Browse files Browse the repository at this point in the history
…alstorage

Signed-off-by: Don Alfons Nisnoni <[email protected]>
  • Loading branch information
itsdonnix committed Feb 20, 2021
1 parent dd75f89 commit 92adaa0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main/frontend/src/stores.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { writable } from 'svelte/store';

export function createLocalStore(key, initialValue) {
const localValue = process.browser ? localStorage.getItem(key) : initialValue;
const localValue =
process.browser && !!localStorage.getItem(key) ? localStorage.getItem(key) : initialValue;
const { subscribe, set } = writable(localValue);

return {
Expand All @@ -10,11 +11,10 @@ export function createLocalStore(key, initialValue) {
if (process.browser) {
localStorage.setItem(key, value);
}
set(value)
set(value);
},
};
}


export const isLoggedIn = writable(true)
export const theme = createLocalStore('theme', 'light')
export const isLoggedIn = writable(true);
export const theme = createLocalStore('theme', 'light');

0 comments on commit 92adaa0

Please sign in to comment.