Regression: Users search on `CreateDiscussionView` (#4112)

* fix: users search on `CreateDiscussionView`

* chore: increased readability for `getUsers` function
This commit is contained in:
Gerzon Z 2022-04-26 14:15:29 -04:00 committed by GitHub
parent c910f8abe1
commit 08271f6114
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -32,7 +32,10 @@ const SelectUsers = ({
const getUsers = debounce(async (keyword = '') => { const getUsers = debounce(async (keyword = '') => {
try { try {
const res = await RocketChat.search({ text: keyword, filterRooms: false }); 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 { } catch {
// do nothing // do nothing
} }