Skip to content

Commit

Permalink
Modify logic to catch exception when casting the theme string to a Th…
Browse files Browse the repository at this point in the history
…emeType and default to 'light' theme (#1653)
  • Loading branch information
grymmy committed May 7, 2024
1 parent 8b5cdc8 commit 0424ea5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/components/big-interactive-pages/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,15 @@ export default function Editor({ persistenceState, cookies }: EditorProps) {
// re-intialize the value of the editing session length to since the editor was opened
editSessionLength.value = new Date();

// load the theme value from localstorage
switchTheme((localStorage.getItem("theme") ?? "light") as ThemeType);
try {
const themeStr = localStorage.getItem("theme") ?? "light"
let theme : ThemeType = themeStr as ThemeType
switchTheme(theme)
} catch (e) {
console.log('Weird theme error (unknown theme?): ' + e)
switchTheme("light" as ThemeType)
}


const updateMaxSize = () => {
maxOutputAreaSize.value = (window.innerWidth - outputAreaWidthMargin) / 2.5
Expand Down

0 comments on commit 0424ea5

Please sign in to comment.