Fix suggested room vanishing when you peek it

This commit is contained in:
Michael Telatynski 2021-03-26 11:48:31 +00:00
parent 9fb653e522
commit aff05eff48

View file

@ -122,7 +122,8 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
const data = await this.fetchSuggestedRooms(space);
if (this._activeSpace === space) {
this._suggestedRooms = data.rooms.filter(roomInfo => {
return roomInfo.room_type !== RoomType.Space && !this.matrixClient.getRoom(roomInfo.room_id);
return roomInfo.room_type !== RoomType.Space
&& this.matrixClient.getRoom(roomInfo.room_id)?.getMyMembership() !== "join";
});
this.emit(SUGGESTED_ROOMS, this._suggestedRooms);
}
@ -380,11 +381,13 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
this.setActiveSpace(room);
}
if (room.getMyMembership() === "join") {
const numSuggestedRooms = this._suggestedRooms.length;
this._suggestedRooms = this._suggestedRooms.filter(r => r.room_id !== room.roomId);
if (numSuggestedRooms !== this._suggestedRooms.length) {
this.emit(SUGGESTED_ROOMS, this._suggestedRooms);
}
}
};
private onRoomState = (ev: MatrixEvent) => {