Merge pull request #4997 from matrix-org/t3chguy/fix/14526
Fix filtering by community not showing DM rooms with community members
This commit is contained in:
commit
725fa7df9b
1 changed files with 10 additions and 4 deletions
|
@ -21,6 +21,7 @@ import { EventEmitter } from "events";
|
||||||
import GroupStore from "../../GroupStore";
|
import GroupStore from "../../GroupStore";
|
||||||
import { arrayHasDiff } from "../../../utils/arrays";
|
import { arrayHasDiff } from "../../../utils/arrays";
|
||||||
import { IDestroyable } from "../../../utils/IDestroyable";
|
import { IDestroyable } from "../../../utils/IDestroyable";
|
||||||
|
import DMRoomMap from "../../../utils/DMRoomMap";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A filter condition for the room list which reveals rooms which
|
* 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 {
|
export class CommunityFilterCondition extends EventEmitter implements IFilterCondition, IDestroyable {
|
||||||
private roomIds: string[] = [];
|
private roomIds: string[] = [];
|
||||||
|
private userIds: string[] = [];
|
||||||
|
|
||||||
constructor(private community: Group) {
|
constructor(private community: Group) {
|
||||||
super();
|
super();
|
||||||
|
@ -43,15 +45,19 @@ export class CommunityFilterCondition extends EventEmitter implements IFilterCon
|
||||||
}
|
}
|
||||||
|
|
||||||
public isVisible(room: Room): boolean {
|
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> => {
|
private onStoreUpdate = async (): Promise<any> => {
|
||||||
// We don't actually know if the room list changed for the community, so just
|
// We don't actually know if the room list changed for the community, so just check it again.
|
||||||
// check it again.
|
|
||||||
const beforeRoomIds = this.roomIds;
|
const beforeRoomIds = this.roomIds;
|
||||||
this.roomIds = (await GroupStore.getGroupRooms(this.community.groupId)).map(r => r.roomId);
|
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);
|
this.emit(FILTER_CHANGED);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue