[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:
parent
c5df938768
commit
5bb5d54327
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue