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

Don't show the same user twice in Spotlight #8978

Merged
merged 11 commits into from
Jul 6, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ const SpotlightDialog: React.FC<IProps> = ({ initialText = "", initialFilter = n
() => {
const roomMembers = findVisibleRoomMembers(cli);
const roomMemberIds = new Set(roomMembers.map(item => item.userId));
justjanne marked this conversation as resolved.
Show resolved Hide resolved
return [
const results = [
...SpaceStore.instance.enabledMetaSpaces.map(spaceKey => ({
section: Section.Spaces,
filter: [],
Expand All @@ -341,6 +341,13 @@ const SpotlightDialog: React.FC<IProps> = ({ initialText = "", initialFilter = n
...(profile ? [new DirectoryMember(profile)] : []).map(toMemberResult),
...publicRooms.map(toPublicRoomResult),
].filter(result => filter === null || result.filter.includes(filter));
// Filter out any IMemberResults for which we have a room
return results.filter((m) => !results.find((r) => {
const userId = m["member"]?.userId;
const roomId = r["room"]?.roomId;
if (!roomId || !userId) return false;
return DMRoomMap.shared().getUserIdForRoomId(roomId) === userId;
SimonBrandner marked this conversation as resolved.
Show resolved Hide resolved
}));
},
[cli, users, profile, publicRooms, filter],
);
Expand Down