mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-16 21:24:59 +08:00
Merge pull request #3657 from matrix-org/dbkr/matchmedia_conditional_events
Make addEventListener conditional
This commit is contained in:
commit
abdf3c4a58
12
src/theme.js
12
src/theme.js
@ -41,14 +41,18 @@ export class ThemeWatcher {
|
||||
start() {
|
||||
this._themeWatchRef = SettingsStore.watchSetting("theme", null, this._onChange);
|
||||
this._systemThemeWatchRef = SettingsStore.watchSetting("use_system_theme", null, this._onChange);
|
||||
this._preferDark.addEventListener('change', this._onChange);
|
||||
this._preferLight.addEventListener('change', this._onChange);
|
||||
if (this._preferDark.addEventListener) {
|
||||
this._preferDark.addEventListener('change', this._onChange);
|
||||
this._preferLight.addEventListener('change', this._onChange);
|
||||
}
|
||||
this._dispatcherRef = dis.register(this._onAction);
|
||||
}
|
||||
|
||||
stop() {
|
||||
this._preferDark.removeEventListener('change', this._onChange);
|
||||
this._preferLight.removeEventListener('change', this._onChange);
|
||||
if (this._preferDark.addEventListener) {
|
||||
this._preferDark.removeEventListener('change', this._onChange);
|
||||
this._preferLight.removeEventListener('change', this._onChange);
|
||||
}
|
||||
SettingsStore.unwatchSetting(this._systemThemeWatchRef);
|
||||
SettingsStore.unwatchSetting(this._themeWatchRef);
|
||||
dis.unregister(this._dispatcherRef);
|
||||
|
Loading…
Reference in New Issue
Block a user