import React from 'react'; import classNames from 'classnames'; import { Avatar, Box, Header, Icon, IconButton, Icons, MenuItem, Scroll, Text, as, config, } from 'folds'; import { Room } from 'matrix-js-sdk'; import { useRoomEventReaders } from '../../hooks/useRoomEventReaders'; import { getMemberDisplayName } from '../../utils/room'; import { getMxIdLocalPart } from '../../utils/matrix'; import * as css from './EventReaders.css'; import { useMatrixClient } from '../../hooks/useMatrixClient'; import { openProfileViewer } from '../../../client/action/navigation'; import { UserAvatar } from '../user-avatar'; import { useSpecVersions } from '../../hooks/useSpecVersions'; export type EventReadersProps = { room: Room; eventId: string; requestClose: () => void; }; export const EventReaders = as<'div', EventReadersProps>( ({ className, room, eventId, requestClose, ...props }, ref) => { const mx = useMatrixClient(); const { versions } = useSpecVersions(); const useAuthentication = versions.includes('v1.11'); const latestEventReaders = useRoomEventReaders(room, eventId); const getName = (userId: string) => getMemberDisplayName(room, userId) ?? getMxIdLocalPart(userId) ?? userId; return (
Seen by
{latestEventReaders.map((readerId) => { const name = getName(readerId); const avatarMxcUrl = room .getMember(readerId) ?.getMxcAvatarUrl(); const avatarUrl = avatarMxcUrl ? mx.mxcUrlToHttp(avatarMxcUrl, 100, 100, 'crop', undefined, false, useAuthentication) : undefined; return ( { requestClose(); openProfileViewer(readerId, room.roomId); }} before={ } /> } > {name} ); })}
); } );