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); const data = await this.fetchSuggestedRooms(space);
if (this._activeSpace === space) { if (this._activeSpace === space) {
this._suggestedRooms = data.rooms.filter(roomInfo => { 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); this.emit(SUGGESTED_ROOMS, this._suggestedRooms);
} }
@ -380,10 +381,12 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
this.setActiveSpace(room); this.setActiveSpace(room);
} }
const numSuggestedRooms = this._suggestedRooms.length; if (room.getMyMembership() === "join") {
this._suggestedRooms = this._suggestedRooms.filter(r => r.room_id !== room.roomId); const numSuggestedRooms = this._suggestedRooms.length;
if (numSuggestedRooms !== this._suggestedRooms.length) { this._suggestedRooms = this._suggestedRooms.filter(r => r.room_id !== room.roomId);
this.emit(SUGGESTED_ROOMS, this._suggestedRooms); if (numSuggestedRooms !== this._suggestedRooms.length) {
this.emit(SUGGESTED_ROOMS, this._suggestedRooms);
}
} }
}; };