From a698e9499c7f0fd83fe32ce12a195576e4b57087 Mon Sep 17 00:00:00 2001 From: diegolmello Date: Fri, 28 Sep 2018 16:20:00 -0300 Subject: [PATCH] [FIX] Search rooms --- app/lib/rocketchat.js | 16 ++++++++-------- app/views/RoomsListView/index.js | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/lib/rocketchat.js b/app/lib/rocketchat.js index 4e653c074f..cbd4c68884 100644 --- a/app/lib/rocketchat.js +++ b/app/lib/rocketchat.js @@ -540,6 +540,11 @@ const RocketChat = { async search({ text, filterUsers = true, filterRooms = true }) { const searchText = text.trim(); + + if (this.oldPromise) { + this.oldPromise('cancel'); + } + if (searchText === '') { delete this.oldPromise; return []; @@ -557,10 +562,6 @@ const RocketChat = { const usernames = data.map(sub => sub.name); try { if (data.length < 7) { - if (this.oldPromise) { - this.oldPromise('cancel'); - } - const { users, rooms } = await Promise.race([ RocketChat.spotlight(searchText, usernames, { users: filterUsers, rooms: filterRooms }), new Promise((resolve, reject) => this.oldPromise = reject) @@ -577,14 +578,13 @@ const RocketChat = { ...room, search: true }))); - - delete this.oldPromise; } - + delete this.oldPromise; return data; } catch (e) { console.warn(e); - return []; + return data; + // return []; } }, diff --git a/app/views/RoomsListView/index.js b/app/views/RoomsListView/index.js index b9f6fd15c1..6d2bca73e2 100644 --- a/app/views/RoomsListView/index.js +++ b/app/views/RoomsListView/index.js @@ -422,7 +422,7 @@ export default class RoomsListView extends LoggedView { renderSearchBar = () => { if (Platform.OS === 'ios') { - return this.search(text)} testID='rooms-list-view-search' />; + return ; } }