From 0424ea5170941be8ae8c22ed0c2339d9719827bf Mon Sep 17 00:00:00 2001 From: graham Date: Tue, 7 May 2024 14:08:13 -0400 Subject: [PATCH] Modify logic to catch exception when casting the theme string to a ThemeType and default to 'light' theme (#1653) --- src/components/big-interactive-pages/editor.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/big-interactive-pages/editor.tsx b/src/components/big-interactive-pages/editor.tsx index 9396c9b70..84d43a2e7 100644 --- a/src/components/big-interactive-pages/editor.tsx +++ b/src/components/big-interactive-pages/editor.tsx @@ -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