Merge pull request #4888 from matrix-org/jryans/rm-dup-compact

Remove duplicate compact settings, handle device level updates
This commit is contained in:
J. Ryan Stinnett 2020-07-03 12:15:52 +01:00 committed by GitHub
commit 67de8f38f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 7 deletions

View file

@ -146,6 +146,7 @@ class LoggedInView extends React.Component<IProps, IState> {
protected readonly _resizeContainer: React.RefObject<ResizeHandle>; protected readonly _resizeContainer: React.RefObject<ResizeHandle>;
protected readonly _sessionStore: sessionStore; protected readonly _sessionStore: sessionStore;
protected readonly _sessionStoreToken: { remove: () => void }; protected readonly _sessionStoreToken: { remove: () => void };
protected readonly _compactLayoutWatcherRef: string;
protected resizer: Resizer; protected resizer: Resizer;
constructor(props, context) { constructor(props, context) {
@ -177,6 +178,10 @@ class LoggedInView extends React.Component<IProps, IState> {
this._matrixClient.on("sync", this.onSync); this._matrixClient.on("sync", this.onSync);
this._matrixClient.on("RoomState.events", this.onRoomStateEvents); this._matrixClient.on("RoomState.events", this.onRoomStateEvents);
this._compactLayoutWatcherRef = SettingsStore.watchSetting(
"useCompactLayout", null, this.onCompactLayoutChanged,
);
fixupColorFonts(); fixupColorFonts();
this._roomView = React.createRef(); this._roomView = React.createRef();
@ -194,6 +199,7 @@ class LoggedInView extends React.Component<IProps, IState> {
this._matrixClient.removeListener("accountData", this.onAccountData); this._matrixClient.removeListener("accountData", this.onAccountData);
this._matrixClient.removeListener("sync", this.onSync); this._matrixClient.removeListener("sync", this.onSync);
this._matrixClient.removeListener("RoomState.events", this.onRoomStateEvents); this._matrixClient.removeListener("RoomState.events", this.onRoomStateEvents);
SettingsStore.unwatchSetting(this._compactLayoutWatcherRef);
if (this._sessionStoreToken) { if (this._sessionStoreToken) {
this._sessionStoreToken.remove(); this._sessionStoreToken.remove();
} }
@ -263,16 +269,17 @@ class LoggedInView extends React.Component<IProps, IState> {
} }
onAccountData = (event) => { onAccountData = (event) => {
if (event.getType() === "im.vector.web.settings") {
this.setState({
useCompactLayout: event.getContent().useCompactLayout,
});
}
if (event.getType() === "m.ignored_user_list") { if (event.getType() === "m.ignored_user_list") {
dis.dispatch({action: "ignore_state_changed"}); dis.dispatch({action: "ignore_state_changed"});
} }
}; };
onCompactLayoutChanged = (setting, roomId, level, valueAtLevel, newValue) => {
this.setState({
useCompactLayout: valueAtLevel,
});
};
onSync = (syncState, oldSyncState, data) => { onSync = (syncState, oldSyncState, data) => {
const oldErrCode = ( const oldErrCode = (
this.state.syncErrorData && this.state.syncErrorData &&

View file

@ -291,7 +291,6 @@ export default class AppearanceUserSettingsTab extends React.Component<IProps, I
/> />
</div> </div>
{customThemeForm} {customThemeForm}
<SettingsFlag name="useCompactLayout" level={SettingLevel.ACCOUNT} useCheckbox={true} />
</div> </div>
); );
} }

View file

@ -202,7 +202,7 @@ export const SETTINGS = {
default: false, default: false,
}, },
"useCompactLayout": { "useCompactLayout": {
supportedLevels: LEVELS_ACCOUNT_SETTINGS, supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS,
displayName: _td('Use a more compact Modern layout'), displayName: _td('Use a more compact Modern layout'),
default: false, default: false,
}, },