Allow finding group DMs by members in spotlight (#8922)

This commit is contained in:
Janne Mareike Koschinski 2022-06-30 11:44:56 +02:00 committed by GitHub
parent 7e47749ce2
commit d4a4eeaf63
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 65 additions and 5 deletions

View file

@ -177,16 +177,20 @@ const toPublicRoomResult = (publicRoom: IPublicRoomsChunkRoom): IPublicRoomResul
});
const toRoomResult = (room: Room): IRoomResult => {
const myUserId = MatrixClientPeg.get().getUserId();
const otherUserId = DMRoomMap.shared().getUserIdForRoomId(room.roomId);
if (otherUserId) {
const otherMembers = room.getMembers().filter(it => it.userId !== myUserId);
const query = [
...otherMembers.map(it => it.name.toLowerCase()),
...otherMembers.map(it => it.userId.toLowerCase()),
].filter(Boolean);
return {
room,
section: Section.People,
filter: [Filter.People],
query: [
otherUserId.toLowerCase(),
room.getMember(otherUserId)?.name.toLowerCase(),
].filter(Boolean),
query,
};
} else if (room.isSpaceRoom()) {
return {

View file

@ -44,7 +44,9 @@ export function roomContextDetailsText(room: Room): string {
if (room.isSpaceRoom()) return undefined;
const dmPartner = DMRoomMap.shared().getUserIdForRoomId(room.roomId);
if (dmPartner) {
// if weve got more than 2 users, dont treat it like a regular DM
const isGroupDm = room.getMembers().length > 2;
if (dmPartner && !isGroupDm) {
return dmPartner;
}