From c66941d3429a59d16b0259232e64d402e2c0c9aa Mon Sep 17 00:00:00 2001 From: Xylight Date: Thu, 25 Jul 2024 12:26:54 -0700 Subject: [PATCH] fix: don't save dynamic themes --- src/lib/ui/colors.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/lib/ui/colors.ts b/src/lib/ui/colors.ts index 7c3382f7..e2edd301 100644 --- a/src/lib/ui/colors.ts +++ b/src/lib/ui/colors.ts @@ -112,7 +112,14 @@ export let themeData = writable( themeData.subscribe((themeData) => { if (browser) { - localStorage.setItem('themeData', JSON.stringify(themeData)) + const filteredThemes = themeData.themes.filter((t) => t.id > 0) + localStorage.setItem( + 'themeData', + JSON.stringify({ + ...themeData, + themes: filteredThemes, + }) + ) } }) @@ -189,7 +196,11 @@ function loadTheme() { const localTheme = localStorage.getItem('themeData') if (localTheme) { - return JSON.parse(localTheme) + const data = JSON.parse(localTheme) + if (!data) return + console.log(data) + data.themes = [...presets, ...data.themes] + return data } return