Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #6713 from matrix-org/t3chguy/fix/18737
Browse files Browse the repository at this point in the history
Fix membership updates to Spaces not applying in real-time
  • Loading branch information
t3chguy authored Aug 31, 2021
2 parents 4e1e304 + b814100 commit e0363dd
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/stores/SpaceStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -678,12 +678,14 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
}
this.emit(room.roomId);
break;
}
};

case EventType.RoomMember:
if (room.isSpaceRoom()) {
this.onSpaceMembersChange(ev);
}
break;
// listening for m.room.member events in onRoomState above doesn't work as the Member object isn't updated by then
private onRoomStateMembers = (ev: MatrixEvent) => {
const room = this.matrixClient.getRoom(ev.getRoomId());
if (room?.isSpaceRoom()) {
this.onSpaceMembersChange(ev);
}
};

Expand Down Expand Up @@ -743,6 +745,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
this.matrixClient.removeListener("Room.myMembership", this.onRoom);
this.matrixClient.removeListener("Room.accountData", this.onRoomAccountData);
this.matrixClient.removeListener("RoomState.events", this.onRoomState);
this.matrixClient.removeListener("RoomState.members", this.onRoomStateMembers);
this.matrixClient.removeListener("accountData", this.onAccountData);
}
await this.reset();
Expand All @@ -754,6 +757,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
this.matrixClient.on("Room.myMembership", this.onRoom);
this.matrixClient.on("Room.accountData", this.onRoomAccountData);
this.matrixClient.on("RoomState.events", this.onRoomState);
this.matrixClient.on("RoomState.members", this.onRoomStateMembers);
this.matrixClient.on("accountData", this.onAccountData);

this.matrixClient.getCapabilities().then(capabilities => {
Expand Down

0 comments on commit e0363dd

Please sign in to comment.