Fix selected theme not loading when refreshing

This commit is contained in:
0xh3xa 2025-03-29 01:27:38 +01:00 committed by GitHub
parent d3357d2acd
commit 49d69a293b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -167,8 +167,12 @@ class OptionsWaiter {
* Applies the user's preferred color scheme using the `prefers-color-scheme` media query.
*/
applyPreferredColorScheme() {
const prefersDarkScheme = window.matchMedia("(prefers-color-scheme: dark)").matches;
const theme = prefersDarkScheme ? "dark" : "classic";
const themeFromStorage = this.app?.options?.theme;
let theme = themeFromStorage;
if (!theme) {
const preferredTheme = (window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "classic");
theme = preferredTheme;
}
this.changeTheme(theme);
}