8dc4c4d072
Fixes N1–N94 findings from LOTUS_BUGS.md audit pass. Key changes: - ProfileDecoration: raw <button> → folds <Button> for save/remove; remove undefined --accent-cyan var - UserRoomProfile: textarea border uses color.SurfaceVariant.ContainerLine and config tokens instead of undefined --border-interactive var - LotusToastContainer: z-index raised from 9997 → 10001 so toasts appear above Night Light overlay (9998) and modals (9999) - Message.tsx: DeliveryStatus replaces Unicode glyphs with Icon components; MessageQuickReactions returns null instead of <span />; forward menu item gets correct size="100" on after icon - AudioContent: speed chip variant/radii now matches Play chip (Secondary/300) - ReadReceiptAvatars: pill border/radius/padding → folds config tokens; remove dead receipt-pill-btn className - EventReaders: Header size 600→500; close button gets radii="300"; borderBottom shorthand → borderBottomWidth token; remove raw fontSize - General.tsx: selected background/seasonal picker border uses color.Primary.Main instead of color.Critical.Main (error red) - RoomInsights: SectionHeader drops textTransform/letterSpacing/opacity; chart borderRadius → config tokens; remove raw fontSize:9; warning banner → SequenceCard - RoomProfile.tsx: formatting toolbar raw <button> → folds <Button>; topic read-mode renders formatted_body via sanitizeCustomHtml - MsgTypeRenderers: location Open button Chip→Button; opacity:0.65→priority - UploadCardRenderer: caption raw <input> → folds <Input> - VoiceMessageRecorder: replace undefined --bg-surface-variant/--tc-* vars with color.* tokens; replace bare <audio controls> with IconButton play/pause toggle - App.tsx: mention highlight uses WCAG 2.1 relative luminance (gamma linearization) instead of simplified approximation; border now rgba semi-transparent instead of same color as background - RoomNavItem: Mute MenuItem icon moved to before prop - SearchFilters: HasLink chip variant="Success" outlined to match filter bar - RoomViewHeader: Server Notice chip radii Pill→300; fix jotai import order - Fix ESLint import/order errors in DeviceVerificationSetup, RoomTopicViewer, MediaGallery, and RoomViewHeader Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
168 lines
5.8 KiB
TypeScript
168 lines
5.8 KiB
TypeScript
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, mxcUrlToHttp } from '../../utils/matrix';
|
|
import * as css from './EventReaders.css';
|
|
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
|
import { UserAvatar } from '../user-avatar';
|
|
import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
|
|
import { useOpenUserRoomProfile } from '../../state/hooks/userRoomProfile';
|
|
import { useSpaceOptionally } from '../../hooks/useSpace';
|
|
import { getMouseEventCords } from '../../utils/dom';
|
|
import { useSetting } from '../../state/hooks/settings';
|
|
import { settingsAtom } from '../../state/settings';
|
|
import { today, yesterday, timeHourMinute, timeMon, timeDay, timeYear } from '../../utils/time';
|
|
|
|
function formatReadTs(ts: number, hour24Clock: boolean): string {
|
|
const timeStr = timeHourMinute(ts, hour24Clock);
|
|
if (today(ts)) return `Today at ${timeStr}`;
|
|
if (yesterday(ts)) return `Yesterday at ${timeStr}`;
|
|
const sameYear = timeYear(ts) === timeYear(Date.now());
|
|
return sameYear
|
|
? `${timeMon(ts)} ${timeDay(ts)} at ${timeStr}`
|
|
: `${timeMon(ts)} ${timeDay(ts)} ${timeYear(ts)} at ${timeStr}`;
|
|
}
|
|
|
|
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 useAuthentication = useMediaAuthentication();
|
|
const myUserId = mx.getUserId();
|
|
const latestEventReaders = useRoomEventReaders(room, eventId).filter((id) => id !== myUserId);
|
|
const openProfile = useOpenUserRoomProfile();
|
|
const space = useSpaceOptionally();
|
|
const [hour24Clock] = useSetting(settingsAtom, 'hour24Clock');
|
|
const [lotusTerminal] = useSetting(settingsAtom, 'lotusTerminal');
|
|
|
|
const getName = (userId: string) =>
|
|
getMemberDisplayName(room, userId) ?? getMxIdLocalPart(userId) ?? userId;
|
|
|
|
return (
|
|
<Box
|
|
className={classNames(css.EventReaders, className)}
|
|
direction="Column"
|
|
{...props}
|
|
ref={ref}
|
|
>
|
|
<Header
|
|
className={css.Header}
|
|
variant="Surface"
|
|
size="500"
|
|
style={
|
|
lotusTerminal
|
|
? {
|
|
borderBottomWidth: config.borderWidth.B300,
|
|
boxShadow: 'var(--lt-box-glow-cyan)',
|
|
}
|
|
: undefined
|
|
}
|
|
>
|
|
<Box grow="Yes">
|
|
<Text
|
|
size="H3"
|
|
style={
|
|
lotusTerminal
|
|
? {
|
|
color: 'var(--lt-accent-cyan)',
|
|
textShadow: 'var(--lt-glow-cyan)',
|
|
letterSpacing: '0.05em',
|
|
}
|
|
: undefined
|
|
}
|
|
>
|
|
Seen by
|
|
</Text>
|
|
</Box>
|
|
<IconButton size="300" radii="300" onClick={requestClose} aria-label="Close">
|
|
<Icon src={Icons.Cross} />
|
|
</IconButton>
|
|
</Header>
|
|
<Box grow="Yes">
|
|
<Scroll visibility="Hover" hideTrack size="300">
|
|
<Box className={css.Content} direction="Column">
|
|
{latestEventReaders.map((readerId) => {
|
|
const name = getName(readerId);
|
|
const avatarMxcUrl = room.getMember(readerId)?.getMxcAvatarUrl();
|
|
const avatarUrl = avatarMxcUrl
|
|
? (mxcUrlToHttp(mx, avatarMxcUrl, useAuthentication, 100, 100, 'crop') ??
|
|
undefined)
|
|
: undefined;
|
|
const receiptTs = room.getReadReceiptForUserId(readerId)?.data.ts;
|
|
|
|
return (
|
|
<MenuItem
|
|
key={readerId}
|
|
style={{ padding: `0 ${config.space.S200}` }}
|
|
radii="400"
|
|
onClick={(event) => {
|
|
openProfile(
|
|
room.roomId,
|
|
space?.roomId,
|
|
readerId,
|
|
getMouseEventCords(event.nativeEvent),
|
|
'Bottom',
|
|
);
|
|
}}
|
|
before={
|
|
<Avatar size="200">
|
|
<UserAvatar
|
|
userId={readerId}
|
|
src={avatarUrl}
|
|
alt={name}
|
|
renderFallback={() => <Icon size="50" src={Icons.User} filled />}
|
|
/>
|
|
</Avatar>
|
|
}
|
|
>
|
|
<Box direction="Column" grow="Yes">
|
|
<Text size="T400" truncate>
|
|
{name}
|
|
</Text>
|
|
{receiptTs !== undefined && (
|
|
<Text
|
|
size="T200"
|
|
priority="300"
|
|
style={
|
|
lotusTerminal
|
|
? {
|
|
color: 'var(--lt-accent-amber)',
|
|
textShadow: 'var(--lt-glow-amber)',
|
|
}
|
|
: undefined
|
|
}
|
|
>
|
|
{formatReadTs(receiptTs, hour24Clock)}
|
|
</Text>
|
|
)}
|
|
</Box>
|
|
</MenuItem>
|
|
);
|
|
})}
|
|
</Box>
|
|
</Scroll>
|
|
</Box>
|
|
</Box>
|
|
);
|
|
},
|
|
);
|