Skip to content

Commit 9f1b279

Browse files
committed
refac
1 parent 8e82f0d commit 9f1b279

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

src/routes/+layout.svelte

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,25 @@
714714
await goto(`/?q=${encodeURIComponent(event.data.query)}`);
715715
return;
716716
}
717+
if (event.type === 'theme:update' && event.data?.theme) {
718+
const newTheme = event.data.theme;
719+
localStorage.setItem('theme', newTheme);
720+
theme.set(newTheme);
721+
722+
// Apply theme classes (mirrors logic from chat/Settings/General.svelte)
723+
const themes = ['dark', 'light', 'oled-dark'];
724+
let themeToApply = newTheme === 'oled-dark' ? 'dark' : newTheme === 'her' ? 'light' : newTheme;
725+
if (newTheme === 'system') {
726+
themeToApply = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
727+
}
728+
themes
729+
.filter((e) => e !== themeToApply)
730+
.forEach((e) => {
731+
e.split(' ').forEach((cls) => document.documentElement.classList.remove(cls));
732+
});
733+
themeToApply.split(' ').forEach((cls) => document.documentElement.classList.add(cls));
734+
return;
735+
}
717736
if (event.type === 'models:refresh') {
718737
const token = localStorage.token;
719738
if (token) {

0 commit comments

Comments
 (0)