From 9628e15fb8da2814c57420d6225027cb322d266b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Espino=20Garc=C3=ADa?= Date: Fri, 31 May 2024 21:10:11 +0200 Subject: [PATCH] Fix user autocomplete not showing users not in channel (#7980) --- app/components/autocomplete/at_mention/at_mention.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/components/autocomplete/at_mention/at_mention.tsx b/app/components/autocomplete/at_mention/at_mention.tsx index 3abd98a71..2fb8b2766 100644 --- a/app/components/autocomplete/at_mention/at_mention.tsx +++ b/app/components/autocomplete/at_mention/at_mention.tsx @@ -298,8 +298,14 @@ const AtMention = ({ if (outOfChannel?.length) { const outChannelMemberIds = outOfChannel.map((e) => e.id); + + // This only get us the users we have on the database. + // We need to append those users from which we don't have + // information at the end of the list. const outSortedMembers = await getUsersFromDMSorted(database, outChannelMemberIds); - sortedMembers.push(...outSortedMembers); + const idSet = new Set(outSortedMembers.map((v) => v.id)); + const outRest = outOfChannel.filter((v) => !idSet.has(v.id)); + sortedMembers.push(...outSortedMembers, ...outRest); } if (hasTrailingSpaces(term)) {