Skip to content

Commit

Permalink
Fix old theme format parsing.
Browse files Browse the repository at this point in the history
  • Loading branch information
Klaster1 committed Jul 1, 2024
1 parent 2a67e52 commit 1117e83
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/app/services/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,13 @@ const withTheme = () => {
onInit(store) {
{
const storedTheme = localStorage.getItem('theme');
const parsedTheme = storedTheme ? JSON.parse(storedTheme) : null;
const theme = typeof parsedTheme === 'object' && parsedTheme ? parsedTheme : initialState.theme;
store.setTheme(theme);
try {
const parsedTheme = storedTheme ? JSON.parse(storedTheme) : null;
const theme = typeof parsedTheme === 'object' && parsedTheme ? parsedTheme : initialState.theme;
store.setTheme(theme);
} catch (e) {
if (initialState.theme) store.setTheme(initialState.theme);
}
}
effect(() => {
const theme = store.theme();
Expand Down

0 comments on commit 1117e83

Please sign in to comment.