Fix local/session storage parsing/stringifying values

The old logic stringifyed all values, including strings, which caused problems with reading external stored values (e.g., mui-mode) via the "useStorage" hook.
This commit is contained in:
schroda
2025-07-28 02:30:25 +02:00
parent fb00f51107
commit ef6c1fce56
4 changed files with 26 additions and 10 deletions

View File

@@ -30,10 +30,11 @@
<script type="module" src="./src/index.tsx"></script>
<script>
const backgroundColor = (() => {
const storageValue = window.localStorage.getItem("theme_background")
try {
return JSON.parse(window.localStorage.getItem("theme_background"))
return JSON.parse(storageValue)
} catch (e) {
return null
return storageValue
}
})();