From 12f6038fa1709f7f869070e5b9a978409fce0fc1 Mon Sep 17 00:00:00 2001 From: Mattermost Build Date: Fri, 3 Oct 2025 14:47:48 +0300 Subject: [PATCH] Fix selected users not showing in add member screen (#9183) (#9186) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix selected users not showing in add member screen * Fix other instances where the set was still treated as an object (cherry picked from commit 240f7c5aab50f3b2c46eaaea64e3d4110e0a91ef) Co-authored-by: Daniel Espino GarcĂ­a --- app/components/selected_users/index.tsx | 8 ++++---- .../channel_add_members/channel_add_members.tsx | 2 +- .../create_direct_message/create_direct_message.tsx | 10 +++------- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/app/components/selected_users/index.tsx b/app/components/selected_users/index.tsx index 4578e8bfb..ec416a2b4 100644 --- a/app/components/selected_users/index.tsx +++ b/app/components/selected_users/index.tsx @@ -32,9 +32,9 @@ type Props = { keyboardOverlap?: number; /** - * A handler function that will select or deselect a user when clicked on. + * A handler function that will trigger when the button is pressed. */ - onPress: (selectedId?: {[id: string]: boolean}) => void; + onPress: () => void; /** * A handler function that will deselect a user when clicked on. @@ -42,7 +42,7 @@ type Props = { onRemove: (id: string) => void; /** - * An object mapping user ids to a falsey value indicating whether or not they have been selected. + * A set of the selected user ids. */ selectedIds: Set; @@ -161,7 +161,7 @@ export default function SelectedUsers({ const usersChipsHeight = useSharedValue(0); const [isVisible, setIsVisible] = useState(false); - const numberSelectedIds = Object.keys(selectedIds).length; + const numberSelectedIds = selectedIds.size; const users = useMemo(() => { const u = []; diff --git a/app/screens/channel_add_members/channel_add_members.tsx b/app/screens/channel_add_members/channel_add_members.tsx index 75a5b45f2..4b45dc797 100644 --- a/app/screens/channel_add_members/channel_add_members.tsx +++ b/app/screens/channel_add_members/channel_add_members.tsx @@ -163,7 +163,7 @@ export default function ChannelAddMembers({ return; } - const idsToUse = Object.keys(selectedIds); + const idsToUse = Array.from(selectedIds); if (!idsToUse.length) { return; } diff --git a/app/screens/create_direct_message/create_direct_message.tsx b/app/screens/create_direct_message/create_direct_message.tsx index e71075f13..9791114e2 100644 --- a/app/screens/create_direct_message/create_direct_message.tsx +++ b/app/screens/create_direct_message/create_direct_message.tsx @@ -152,14 +152,14 @@ export default function CreateDirectMessage({ return !result.error; }, [intl, serverUrl]); - const startConversation = useCallback(async (selectedId?: {[id: string]: boolean}) => { + const startConversation = useCallback(async (selectedId?: string) => { if (startingConversation) { return; } setStartingConversation(true); - const idsToUse = selectedId ? Object.keys(selectedId) : Object.keys(selectedIds); + const idsToUse = selectedId ? [selectedId] : Array.from(selectedIds); let success; if (idsToUse.length === 0) { success = false; @@ -178,11 +178,7 @@ export default function CreateDirectMessage({ const handleSelectProfile = useCallback((user: UserProfile) => { if (user.id === currentUserId) { - const selectedId = { - [currentUserId]: true, - }; - - startConversation(selectedId); + startConversation(currentUserId); } else { clearSearch(); setSelectedIds((current) => {