diff --git a/src/components/views/right_panel/RoomSummaryCard.tsx b/src/components/views/right_panel/RoomSummaryCard.tsx index 4ce4b75f9b..3617def7aa 100644 --- a/src/components/views/right_panel/RoomSummaryCard.tsx +++ b/src/components/views/right_panel/RoomSummaryCard.tsx @@ -43,6 +43,7 @@ import RoomContext from "../../../contexts/RoomContext"; import {UIFeature} from "../../../settings/UIFeature"; import {ChevronFace, ContextMenuTooltipButton, useContextMenu} from "../../structures/ContextMenu"; import WidgetContextMenu from "../context_menus/WidgetContextMenu"; +import {useRoomMembers} from "../../../hooks/useRoomMembers"; interface IProps { room: Room; @@ -210,14 +211,6 @@ const onRoomSettingsClick = () => { defaultDispatcher.dispatch({ action: "open_room_settings" }); }; -const useMemberCount = (room: Room) => { - const [count, setCount] = useState(room.getJoinedMembers().length); - useEventEmitter(room.currentState, "RoomState.members", () => { - setCount(room.getJoinedMembers().length); - }); - return count; -}; - const RoomSummaryCard: React.FC = ({ room, onClose }) => { const cli = useContext(MatrixClientContext); @@ -251,12 +244,12 @@ const RoomSummaryCard: React.FC = ({ room, onClose }) => { ; - const memberCount = useMemberCount(room); + const members = useRoomMembers(room); return