Skip to content

Commit d97b8bc

Browse files
authored
Merge pull request matrix-org#4889 from matrix-org/jryans/rm-dup-compact-release
Remove duplicate compact settings, handle device level updates
2 parents f9cb0b9 + 8bb3f4a commit d97b8bc

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

src/components/structures/LoggedInView.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ class LoggedInView extends React.Component<IProps, IState> {
146146
protected readonly _resizeContainer: React.RefObject<ResizeHandle>;
147147
protected readonly _sessionStore: sessionStore;
148148
protected readonly _sessionStoreToken: { remove: () => void };
149+
protected readonly _compactLayoutWatcherRef: string;
149150
protected resizer: Resizer;
150151

151152
constructor(props, context) {
@@ -177,6 +178,10 @@ class LoggedInView extends React.Component<IProps, IState> {
177178
this._matrixClient.on("sync", this.onSync);
178179
this._matrixClient.on("RoomState.events", this.onRoomStateEvents);
179180

181+
this._compactLayoutWatcherRef = SettingsStore.watchSetting(
182+
"useCompactLayout", null, this.onCompactLayoutChanged,
183+
);
184+
180185
fixupColorFonts();
181186

182187
this._roomView = React.createRef();
@@ -194,6 +199,7 @@ class LoggedInView extends React.Component<IProps, IState> {
194199
this._matrixClient.removeListener("accountData", this.onAccountData);
195200
this._matrixClient.removeListener("sync", this.onSync);
196201
this._matrixClient.removeListener("RoomState.events", this.onRoomStateEvents);
202+
SettingsStore.unwatchSetting(this._compactLayoutWatcherRef);
197203
if (this._sessionStoreToken) {
198204
this._sessionStoreToken.remove();
199205
}
@@ -263,16 +269,17 @@ class LoggedInView extends React.Component<IProps, IState> {
263269
}
264270

265271
onAccountData = (event) => {
266-
if (event.getType() === "im.vector.web.settings") {
267-
this.setState({
268-
useCompactLayout: event.getContent().useCompactLayout,
269-
});
270-
}
271272
if (event.getType() === "m.ignored_user_list") {
272273
dis.dispatch({action: "ignore_state_changed"});
273274
}
274275
};
275276

277+
onCompactLayoutChanged = (setting, roomId, level, valueAtLevel, newValue) => {
278+
this.setState({
279+
useCompactLayout: valueAtLevel,
280+
});
281+
};
282+
276283
onSync = (syncState, oldSyncState, data) => {
277284
const oldErrCode = (
278285
this.state.syncErrorData &&

src/components/views/settings/tabs/user/AppearanceUserSettingsTab.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,6 @@ export default class AppearanceUserSettingsTab extends React.Component<IProps, I
291291
/>
292292
</div>
293293
{customThemeForm}
294-
<SettingsFlag name="useCompactLayout" level={SettingLevel.ACCOUNT} useCheckbox={true} />
295294
</div>
296295
);
297296
}

src/settings/Settings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ export const SETTINGS = {
202202
default: false,
203203
},
204204
"useCompactLayout": {
205-
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
205+
supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS,
206206
displayName: _td('Use a more compact ‘Modern’ layout'),
207207
default: false,
208208
},

0 commit comments

Comments
 (0)