[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 <diegolmello@gmail.com>
This commit is contained in:
Reinaldo Neto 2021-09-28 16:34:14 -03:00 committed by GitHub
parent c5df938768
commit 5bb5d54327
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -1039,7 +1039,7 @@ const RocketChat = {
} }
return this.post('subscriptions.read', { rid: roomId }); 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; const serverVersion = reduxStore.getState().server.version;
if (compareServerVersion(serverVersion, '3.16.0', methods.greaterThanOrEqualTo)) { if (compareServerVersion(serverVersion, '3.16.0', methods.greaterThanOrEqualTo)) {
const params = { const params = {
@ -1050,10 +1050,12 @@ const RocketChat = {
...(filter && { filter }) ...(filter && { filter })
}; };
// RC 3.16.0 // 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 // 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) { methodCallWrapper(method, ...params) {
const { API_Use_REST_For_DDP_Calls } = reduxStore.getState().settings; const { API_Use_REST_For_DDP_Calls } = reduxStore.getState().settings;

View File

@ -434,7 +434,6 @@ class RoomMembersView extends React.Component {
fetchMembers = async () => { fetchMembers = async () => {
const { rid, members, isLoading, allUsers, end, room, filtering } = this.state; const { rid, members, isLoading, allUsers, end, room, filtering } = this.state;
const { t } = room; const { t } = room;
let newMembers;
if (isLoading || end) { if (isLoading || end) {
return; return;
} }
@ -449,11 +448,10 @@ class RoomMembersView extends React.Component {
skip: members.length, skip: members.length,
limit: PAGE_SIZE limit: PAGE_SIZE
}); });
newMembers = membersResult.members;
this.setState({ this.setState({
members: members.concat(newMembers || []), members: members.concat(membersResult || []),
isLoading: false, isLoading: false,
end: newMembers.length < PAGE_SIZE end: membersResult?.length < PAGE_SIZE
}); });
this.setHeader(); this.setHeader();
} catch (e) { } catch (e) {