Ratatoskr/src/app/features/room/RoomViewPoseStatus.tsx
Void a1101e90a6
Some checks failed
Check PR title / lint (pull_request_target) Has been cancelled
Build pull request / Build pull request (pull_request) Has been cancelled
CLA Assistant / CLAssistant (pull_request_target) Failing after 1s
poses: read labels only from the catalogue; add a client-status pose line
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>
2026-11-04 14:06:18 +00:00

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>
);
}