From 4aeb21148d5a389420d09d1ba23a46bbbd2f4839 Mon Sep 17 00:00:00 2001 From: Gerzon Z Date: Tue, 12 Apr 2022 09:48:28 -0400 Subject: [PATCH] [FIX] Searching for users when creating discussions not returning data correctly (#4034) --- .../CreateDiscussionView/SelectUsers.tsx | 26 +------------------ 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/app/views/CreateDiscussionView/SelectUsers.tsx b/app/views/CreateDiscussionView/SelectUsers.tsx index 39d77f47..f82973a8 100644 --- a/app/views/CreateDiscussionView/SelectUsers.tsx +++ b/app/views/CreateDiscussionView/SelectUsers.tsx @@ -1,12 +1,10 @@ import React, { useState } from 'react'; import { Text } from 'react-native'; import { BLOCK_CONTEXT } from '@rocket.chat/ui-kit'; -import { Q } from '@nozbe/watermelondb'; import debounce from '../../utils/debounce'; import { avatarURL } from '../../utils/avatar'; import RocketChat from '../../lib/rocketchat'; -import database from '../../lib/database'; import I18n from '../../i18n'; import { MultiSelect } from '../../containers/UIKit/MultiSelect'; import { themes } from '../../lib/constants'; @@ -33,30 +31,8 @@ const SelectUsers = ({ const getUsers = debounce(async (keyword = '') => { try { - const db = database.active; - const usersCollection = db.get('users'); const res = await RocketChat.search({ text: keyword, filterRooms: false }); - let items = [ - ...users.filter((u: IUser) => selected.includes(u.name)), - ...res.filter(r => !users.find((u: IUser) => u.name === r.name)) - ]; - const records = await usersCollection.query(Q.where('username', Q.oneOf(items.map(u => u.name)))).fetch(); - items = items.map(item => { - const index = records.findIndex(r => r.username === item.name); - if (index > -1) { - const record = records[index]; - return { - uids: item.uids, - usernames: item.usernames, - prid: item.prid, - fname: item.fname, - name: item.name, - avatarETag: record.avatarETag - }; - } - return item; - }); - setUsers(items); + setUsers(res); } catch { // do nothing }