From 08271f6114bc87bf2da59c7588b4a9ca86eee0d7 Mon Sep 17 00:00:00 2001 From: Gerzon Z Date: Tue, 26 Apr 2022 14:15:29 -0400 Subject: [PATCH] Regression: Users search on `CreateDiscussionView` (#4112) * fix: users search on `CreateDiscussionView` * chore: increased readability for `getUsers` function --- app/views/CreateDiscussionView/SelectUsers.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/views/CreateDiscussionView/SelectUsers.tsx b/app/views/CreateDiscussionView/SelectUsers.tsx index f82973a82..26c3291d9 100644 --- a/app/views/CreateDiscussionView/SelectUsers.tsx +++ b/app/views/CreateDiscussionView/SelectUsers.tsx @@ -32,7 +32,10 @@ const SelectUsers = ({ const getUsers = debounce(async (keyword = '') => { try { const res = await RocketChat.search({ text: keyword, filterRooms: false }); - setUsers(res); + const selectedUsers = users.filter((u: IUser) => selected.includes(u.name)); + const filteredUsers = res.filter(r => !users.find((u: IUser) => u.name === r.name)); + const items = [...selectedUsers, ...filteredUsers]; + setUsers(items); } catch { // do nothing }