Skip to content

Commit 25ec98b

Browse files
committed
fix #1941: throttle scheme change
1 parent e9eb9fc commit 25ec98b

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

src/background/color-scheme.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ function update(type, val) {
126126
if (isDark !== val) {
127127
isDark = val;
128128
if (isDark !== notified && saved != null)
129-
debounce(notify);
129+
debounce(notify, 100);
130130
}
131131
}
132132

src/background/style-manager/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,9 @@ export function getRemoteInfo(id) {
169169

170170
/** @returns {Injection.Response} */
171171
export function getSectionsByUrl(url, {id, init, dark} = {}) {
172-
if (dark != null)
172+
// Init the scheme once, then rely on matchMedia->onchange event
173+
// TODO: rework caching to set just the sender's scheme i.e. not globally
174+
if (dark != null && colorScheme.isDark == null)
173175
colorScheme.setSystemDark(dark);
174176
const p = prefs.__values;
175177
if (init && p.disableAll) {

0 commit comments

Comments
 (0)