The client's own SHARED_POSES/MIND_POSES lists and the committed webp art are gone. catalogue.json (cast-art poses/catalogue.json, synced by npm run sync:poses) is the only list of Minds, labels and art paths. RoomViewPoseStatus draws "Ratatoskr: <Mind> is <pose>, since HH:MM" from the loaded timeline; it is never sent to a room. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
53 lines
1.7 KiB
TypeScript
53 lines
1.7 KiB
TypeScript
import React, { useEffect, useState } from 'react';
|
|
import { Box, Text } from 'folds';
|
|
import { Room, RoomEvent } from 'matrix-js-sdk';
|
|
import { settingsAtom } from '../../state/settings';
|
|
import { useSetting } from '../../state/hooks/settings';
|
|
import { getMxIdLocalPart } from '../../utils/matrix';
|
|
import { getMemberDisplayName } from '../../utils/room';
|
|
import { POSE_KEY, poseStatusLine, poseStatuses } from '../../components/message/pose/poses';
|
|
|
|
// Client-status lines about each Mind's current pose. They are drawn from the
|
|
// timeline already in memory and are never sent as anyone's message.
|
|
export function RoomViewPoseStatus({ room }: { room: Room }) {
|
|
const [poseBubbles] = useSetting(settingsAtom, 'poseBubbles');
|
|
const [, bump] = useState(0);
|
|
|
|
useEffect(() => {
|
|
const onTimeline = () => bump((n) => n + 1);
|
|
room.on(RoomEvent.Timeline, onTimeline);
|
|
return () => {
|
|
room.removeListener(RoomEvent.Timeline, onTimeline);
|
|
};
|
|
}, [room]);
|
|
|
|
if (!poseBubbles) return null;
|
|
|
|
const statuses = poseStatuses(
|
|
room
|
|
.getLiveTimeline()
|
|
.getEvents()
|
|
.filter((e) => e.getType() === 'm.room.message' && e.getSender())
|
|
.map((e) => {
|
|
const sender = e.getSender() as string;
|
|
return {
|
|
sender,
|
|
localpart: getMxIdLocalPart(sender),
|
|
name: getMemberDisplayName(room, sender),
|
|
ts: e.getTs(),
|
|
label: e.getContent()[POSE_KEY],
|
|
};
|
|
})
|
|
);
|
|
if (statuses.length === 0) return null;
|
|
|
|
return (
|
|
<Box direction="Column" style={{ padding: '0 1rem' }}>
|
|
{statuses.map((s) => (
|
|
<Text key={s.mind} size="T200" priority="300">
|
|
{poseStatusLine(s)}
|
|
</Text>
|
|
))}
|
|
</Box>
|
|
);
|
|
}
|