You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-07 10:46:24 +03:00
Also use getJoinedMemberCount as its capable of using the room summary member count instead
Leave the useRoomMembers hook for future use as it is very useful.
This commit is contained in:
@@ -29,3 +29,11 @@ export const useRoomMembers = (room: Room, throttleWait = 250) => {
|
||||
}, throttleWait, {leading: true, trailing: true}));
|
||||
return members;
|
||||
};
|
||||
|
||||
export const useRoomMemberCount = (room: Room, throttleWait = 250) => {
|
||||
const [count, setCount] = useState<number>(room.getJoinedMemberCount());
|
||||
useEventEmitter(room.currentState, "RoomState.members", throttle(() => {
|
||||
setCount(room.getJoinedMemberCount());
|
||||
}, throttleWait, {leading: true, trailing: true}));
|
||||
return count;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user