mirror of
https://github.com/element-hq/element-web
synced 2024-11-24 18:25:49 +03:00
Make addEventListener conditional
Safari doesn't support addEventListener
This commit is contained in:
parent
ef475bbdad
commit
521cbbac74
1 changed files with 8 additions and 4 deletions
12
src/theme.js
12
src/theme.js
|
@ -41,14 +41,18 @@ export class ThemeWatcher {
|
||||||
start() {
|
start() {
|
||||||
this._themeWatchRef = SettingsStore.watchSetting("theme", null, this._onChange);
|
this._themeWatchRef = SettingsStore.watchSetting("theme", null, this._onChange);
|
||||||
this._systemThemeWatchRef = SettingsStore.watchSetting("use_system_theme", null, this._onChange);
|
this._systemThemeWatchRef = SettingsStore.watchSetting("use_system_theme", null, this._onChange);
|
||||||
this._preferDark.addEventListener('change', this._onChange);
|
if (this._preferDark.addEventListener) {
|
||||||
this._preferLight.addEventListener('change', this._onChange);
|
this._preferDark.addEventListener('change', this._onChange);
|
||||||
|
this._preferLight.addEventListener('change', this._onChange);
|
||||||
|
}
|
||||||
this._dispatcherRef = dis.register(this._onAction);
|
this._dispatcherRef = dis.register(this._onAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
this._preferDark.removeEventListener('change', this._onChange);
|
if (this._preferDark.addEventListener) {
|
||||||
this._preferLight.removeEventListener('change', this._onChange);
|
this._preferDark.removeEventListener('change', this._onChange);
|
||||||
|
this._preferLight.removeEventListener('change', this._onChange);
|
||||||
|
}
|
||||||
SettingsStore.unwatchSetting(this._systemThemeWatchRef);
|
SettingsStore.unwatchSetting(this._systemThemeWatchRef);
|
||||||
SettingsStore.unwatchSetting(this._themeWatchRef);
|
SettingsStore.unwatchSetting(this._themeWatchRef);
|
||||||
dis.unregister(this._dispatcherRef);
|
dis.unregister(this._dispatcherRef);
|
||||||
|
|
Loading…
Reference in a new issue