From 5bb5d543279aa855d78991bafb2f4d241c5caafa Mon Sep 17 00:00:00 2001 From: Reinaldo Neto <47038980+reinaldonetof@users.noreply.github.com> Date: Tue, 28 Sep 2021 16:34:14 -0300 Subject: [PATCH] [FIX] Fetch members on RoomMembersView (#3403) * [FIX] Fetch members on RoomMembersView * needed to add a conditional to the response * result back properly from rocketchat lib Co-authored-by: Diego Mello --- app/lib/rocketchat.js | 8 +++++--- app/views/RoomMembersView/index.js | 6 ++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/lib/rocketchat.js b/app/lib/rocketchat.js index 02e0cf102..4fd4bdb5a 100644 --- a/app/lib/rocketchat.js +++ b/app/lib/rocketchat.js @@ -1039,7 +1039,7 @@ const RocketChat = { } return this.post('subscriptions.read', { rid: roomId }); }, - getRoomMembers({ rid, allUsers, roomType, type, filter, skip = 0, limit = 10 }) { + async getRoomMembers({ rid, allUsers, roomType, type, filter, skip = 0, limit = 10 }) { const serverVersion = reduxStore.getState().server.version; if (compareServerVersion(serverVersion, '3.16.0', methods.greaterThanOrEqualTo)) { const params = { @@ -1050,10 +1050,12 @@ const RocketChat = { ...(filter && { filter }) }; // RC 3.16.0 - return this.sdk.get(`${this.roomTypeToApiType(roomType)}.members`, params); + const result = await this.sdk.get(`${this.roomTypeToApiType(roomType)}.members`, params); + return result?.members; } // RC 0.42.0 - return this.methodCallWrapper('getUsersOfRoom', rid, allUsers, { skip, limit }); + const result = await this.methodCallWrapper('getUsersOfRoom', rid, allUsers, { skip, limit }); + return result?.records; }, methodCallWrapper(method, ...params) { const { API_Use_REST_For_DDP_Calls } = reduxStore.getState().settings; diff --git a/app/views/RoomMembersView/index.js b/app/views/RoomMembersView/index.js index c4a5ca7ab..308946982 100644 --- a/app/views/RoomMembersView/index.js +++ b/app/views/RoomMembersView/index.js @@ -434,7 +434,6 @@ class RoomMembersView extends React.Component { fetchMembers = async () => { const { rid, members, isLoading, allUsers, end, room, filtering } = this.state; const { t } = room; - let newMembers; if (isLoading || end) { return; } @@ -449,11 +448,10 @@ class RoomMembersView extends React.Component { skip: members.length, limit: PAGE_SIZE }); - newMembers = membersResult.members; this.setState({ - members: members.concat(newMembers || []), + members: members.concat(membersResult || []), isLoading: false, - end: newMembers.length < PAGE_SIZE + end: membersResult?.length < PAGE_SIZE }); this.setHeader(); } catch (e) {