mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2026-01-07 16:05:12 +08:00
try caching adding event listener
This commit is contained in:
parent
6d0966eea0
commit
47273b1907
1 changed files with 14 additions and 10 deletions
|
|
@ -263,16 +263,20 @@ export function applyCustomBackground(): void {
|
|||
}
|
||||
}
|
||||
|
||||
window
|
||||
.matchMedia("(prefers-color-scheme: dark)")
|
||||
?.addEventListener("change", (event) => {
|
||||
if (!Config.autoSwitchTheme || Config.customTheme) return;
|
||||
if (event.matches) {
|
||||
set(Config.themeDark, false);
|
||||
} else {
|
||||
set(Config.themeLight, false);
|
||||
}
|
||||
});
|
||||
try {
|
||||
window
|
||||
.matchMedia("(prefers-color-scheme: dark)")
|
||||
?.addEventListener("change", (event) => {
|
||||
if (!Config.autoSwitchTheme || Config.customTheme) return;
|
||||
if (event.matches) {
|
||||
set(Config.themeDark, false);
|
||||
} else {
|
||||
set(Config.themeLight, false);
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
//
|
||||
}
|
||||
|
||||
ConfigEvent.subscribe((eventKey, eventValue, nosave) => {
|
||||
if (eventKey === "customTheme") {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue