// gomuks - A Matrix client written in Go. // Copyright (C) 2024 Tulir Asokan // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . import { use, useCallback, useState } from "react" import { getAvatarURL } from "@/api/media.ts" import { useRoomMembers } from "@/api/statestore" import { MemDBEvent, MemberEventContent } from "@/api/types" import { getDisplayname } from "@/util/validation.ts" import MainScreenContext from "../MainScreenContext.ts" import { RoomContext } from "../roomview/roomcontext.ts" interface MemberRowProps { evt: MemDBEvent onClick: (evt: React.MouseEvent) => void } const MemberRow = ({ evt, onClick }: MemberRowProps) => { const userID = evt.state_key! const content = evt.content as MemberEventContent return
{getDisplayname(userID, content)}
} const MemberList = () => { const [limit, setLimit] = useState(50) const increaseLimit = useCallback(() => setLimit(limit => limit + 50), []) const roomCtx = use(RoomContext) const memberEvents = useRoomMembers(roomCtx?.store) if (!roomCtx) { return null } const mainScreen = use(MainScreenContext) const members = [] for (const evt of memberEvents) { members.push() if (members.length >= limit) { break } } return <> {members} {memberEvents.length > limit ? : null} } export default MemberList