mirror of
https://github.com/element-hq/element-web
synced 2024-11-27 03:36:07 +03:00
Use a settings watcher to set the theme
Rather than listening for account data updates manually
This commit is contained in:
parent
a0dbd5f62c
commit
80ee68a42f
2 changed files with 12 additions and 11 deletions
|
@ -274,6 +274,7 @@ export default createReactClass({
|
|||
|
||||
componentDidMount: function() {
|
||||
this.dispatcherRef = dis.register(this.onAction);
|
||||
this._themeWatchRef = SettingsStore.watchSetting("theme", null, this._onThemeChanged);
|
||||
|
||||
this.focusComposer = false;
|
||||
|
||||
|
@ -360,6 +361,7 @@ export default createReactClass({
|
|||
componentWillUnmount: function() {
|
||||
Lifecycle.stopMatrixClient();
|
||||
dis.unregister(this.dispatcherRef);
|
||||
SettingsStore.unwatchSetting(this._themeWatchRef);
|
||||
window.removeEventListener("focus", this.onFocus);
|
||||
window.removeEventListener('resize', this.handleResize);
|
||||
this.state.resizeNotifier.removeListener("middlePanelResized", this._dispatchTimelineResize);
|
||||
|
@ -382,6 +384,13 @@ export default createReactClass({
|
|||
}
|
||||
},
|
||||
|
||||
_onThemeChanged: function(settingName, roomId, atLevel, newValue) {
|
||||
dis.dispatch({
|
||||
action: 'set_theme',
|
||||
value: newValue,
|
||||
});
|
||||
},
|
||||
|
||||
startPageChangeTimer() {
|
||||
// Tor doesn't support performance
|
||||
if (!performance || !performance.mark) return null;
|
||||
|
@ -1376,17 +1385,6 @@ export default createReactClass({
|
|||
}, null, true);
|
||||
});
|
||||
|
||||
cli.on("accountData", function(ev) {
|
||||
if (ev.getType() === 'im.vector.web.settings') {
|
||||
if (ev.getContent() && ev.getContent().theme) {
|
||||
dis.dispatch({
|
||||
action: 'set_theme',
|
||||
value: ev.getContent().theme,
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const dft = new DecryptionFailureTracker((total, errorCode) => {
|
||||
Analytics.trackEvent('E2E', 'Decryption failure', errorCode, total);
|
||||
}, (errorCode) => {
|
||||
|
|
|
@ -175,6 +175,9 @@ export default class GeneralUserSettingsTab extends React.Component {
|
|||
|
||||
SettingsStore.setValue("theme", null, SettingLevel.ACCOUNT, newTheme);
|
||||
this.setState({theme: newTheme});
|
||||
// The settings watcher doesn't fire until the echo comes back from the
|
||||
// server, so to make the theme change immediately we need to manually
|
||||
// do the dispatch now
|
||||
dis.dispatch({action: 'set_theme', value: newTheme});
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue