From e53c25fec55414614c6ab229d01e72d4c042da59 Mon Sep 17 00:00:00 2001 From: John Tore Simonsen Date: Wed, 14 Aug 2024 17:04:39 +0200 Subject: [PATCH 1/2] Generate a string arary of userIds in current space, and use list to filter suggestions list and recent list. --- src/components/views/dialogs/InviteDialog.tsx | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/components/views/dialogs/InviteDialog.tsx b/src/components/views/dialogs/InviteDialog.tsx index 6b178595fc8..ed92761d1c3 100644 --- a/src/components/views/dialogs/InviteDialog.tsx +++ b/src/components/views/dialogs/InviteDialog.tsx @@ -75,6 +75,7 @@ import { NonEmptyArray } from "../../../@types/common"; import { SdkContextClass } from "../../../contexts/SDKContext"; import { UserProfilesStore } from "../../../stores/UserProfilesStore"; import { Key } from "../../../Keyboard"; +import SpaceStore from "../../../stores/spaces/SpaceStore"; // we have a number of types defined from the Matrix spec which can't reasonably be altered here. /* eslint-disable camelcase */ @@ -425,10 +426,20 @@ export default class InviteDialog extends React.PureComponent { + console.log(m); + this.spaceMemberIds.push(m.userId); + }); + // Verji end if (props.kind === InviteKind.Invite && !props.roomId) { throw new Error("When using InviteKind.Invite a roomId is required for an InviteDialog"); } else if (props.kind === InviteKind.CallTransfer && !props.call) { @@ -458,7 +469,7 @@ export default class InviteDialog extends React.PureComponent excludedTargetIds.add(id)); } - public static buildRecents(excludedTargetIds: Set): Result[] { + // VERJI added param activeSpaceMembers - used to fileter the recents based on membership in space + public static buildRecents(excludedTargetIds: Set, activeSpaceMembers: string[]): Result[] { const rooms = DMRoomMap.shared().getUniqueRoomsWithIndividuals(); // map of userId => js-sdk Room // Also pull in all the rooms tagged as DefaultTagID.DM so we don't miss anything. Sometimes the @@ -553,6 +565,15 @@ export default class InviteDialog extends React.PureComponent b.lastActive - a.lastActive); return recents; @@ -603,6 +624,7 @@ export default class InviteDialog extends React.PureComponent member) .filter((member) => !excludedTargetIds.has(member.userId)) + .filter((member) => this.spaceMemberIds.includes(member.userId)) // Verji - add another layer of filtering, to only include members which are a member of space .sort(memberComparator) .map((member) => ({ userId: member.userId, user: toMember(member) })); } From 6efa567bc8cb1d800e5775b980365e97ec01e43f Mon Sep 17 00:00:00 2001 From: John Tore Simonsen Date: Wed, 14 Aug 2024 17:34:22 +0200 Subject: [PATCH 2/2] fix type-o --- src/components/views/dialogs/InviteDialog.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/dialogs/InviteDialog.tsx b/src/components/views/dialogs/InviteDialog.tsx index ed92761d1c3..028ca629ae6 100644 --- a/src/components/views/dialogs/InviteDialog.tsx +++ b/src/components/views/dialogs/InviteDialog.tsx @@ -608,7 +608,7 @@ export default class InviteDialog extends React.PureComponent b.lastActive - a.lastActive); return recents;