ensure metaspace changes correctly notify listeners (#8611)

This commit is contained in:
Janne Mareike Koschinski 2022-05-18 15:15:25 +02:00 committed by GitHub
parent 9b92eca73d
commit 2d386556a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 0 deletions

View file

@ -1072,6 +1072,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
?.["m.room_versions"]?.["org.matrix.msc3244.room_capabilities"]?.["restricted"];
});
const oldMetaSpaces = this._enabledMetaSpaces;
const enabledMetaSpaces = SettingsStore.getValue("Spaces.enabledMetaSpaces");
this._enabledMetaSpaces = metaSpaceOrder.filter(k => enabledMetaSpaces[k]);
@ -1079,6 +1080,11 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
this.sendUserProperties();
this.rebuildSpaceHierarchy(); // trigger an initial update
// rebuildSpaceHierarchy will only send an update if the spaces have changed.
// If only the meta spaces have changed, we need to send an update ourselves.
if (arrayHasDiff(oldMetaSpaces, this._enabledMetaSpaces)) {
this.emit(UPDATE_TOP_LEVEL_SPACES, this.spacePanelSpaces, this.enabledMetaSpaces);
}
// restore selected state from last session if any and still valid
const lastSpaceId = window.localStorage.getItem(ACTIVE_SPACE_LS_KEY);