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:
parent
184c73cca4
commit
ecb0b0113f
2 changed files with 11 additions and 3 deletions
|
@ -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;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue