Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Allow finding group DMs by members in spotlight #8922

Merged
merged 6 commits into from
Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/components/views/dialogs/spotlight/SpotlightDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,16 +180,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 {
Expand Down
4 changes: 3 additions & 1 deletion src/utils/i18n-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 we’ve got more than 2 users, don’t treat it like a regular DM
const isGroupDm = room.getMembers().length > 2;
if (dmPartner && !isGroupDm) {
return dmPartner;
}

Expand Down