mirror of
https://github.com/element-hq/element-web
synced 2024-11-28 04:21:57 +03:00
Fix filtering by community not showing DM rooms with community members
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
6bf5b5ff2b
commit
3498922882
1 changed files with 10 additions and 4 deletions
|
@ -21,6 +21,7 @@ import { EventEmitter } from "events";
|
|||
import GroupStore from "../../GroupStore";
|
||||
import { arrayHasDiff } from "../../../utils/arrays";
|
||||
import { IDestroyable } from "../../../utils/IDestroyable";
|
||||
import DMRoomMap from "../../../utils/DMRoomMap";
|
||||
|
||||
/**
|
||||
* A filter condition for the room list which reveals rooms which
|
||||
|
@ -28,6 +29,7 @@ import { IDestroyable } from "../../../utils/IDestroyable";
|
|||
*/
|
||||
export class CommunityFilterCondition extends EventEmitter implements IFilterCondition, IDestroyable {
|
||||
private roomIds: string[] = [];
|
||||
private userIds: string[] = [];
|
||||
|
||||
constructor(private community: Group) {
|
||||
super();
|
||||
|
@ -43,15 +45,19 @@ export class CommunityFilterCondition extends EventEmitter implements IFilterCon
|
|||
}
|
||||
|
||||
public isVisible(room: Room): boolean {
|
||||
return this.roomIds.includes(room.roomId);
|
||||
return this.roomIds.includes(room.roomId) ||
|
||||
this.userIds.includes(DMRoomMap.shared().getUserIdForRoomId(room.roomId));
|
||||
}
|
||||
|
||||
private onStoreUpdate = async (): Promise<any> => {
|
||||
// We don't actually know if the room list changed for the community, so just
|
||||
// check it again.
|
||||
// We don't actually know if the room list changed for the community, so just check it again.
|
||||
const beforeRoomIds = this.roomIds;
|
||||
this.roomIds = (await GroupStore.getGroupRooms(this.community.groupId)).map(r => r.roomId);
|
||||
if (arrayHasDiff(beforeRoomIds, this.roomIds)) {
|
||||
|
||||
const beforeUserIds = this.userIds;
|
||||
this.userIds = (await GroupStore.getGroupMembers(this.community.groupId)).map(u => u.userId);
|
||||
|
||||
if (arrayHasDiff(beforeRoomIds, this.roomIds) || arrayHasDiff(beforeUserIds, this.userIds)) {
|
||||
this.emit(FILTER_CHANGED);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue