show draft message in thread selector

This commit is contained in:
Ajay Bura 2026-08-16 12:15:49 +05:30
commit e95305c1a0
2 changed files with 28 additions and 11 deletions

View file

@ -204,6 +204,7 @@ export function RoomTimeline({ eventId, roomInputRef, editor, timeline }: RoomTi
]
);
const activeThread = useObservableValue(timeline.activeThread);
const threads = useObservableValue(timeline.threads);
const redacted = useObservableValue(timeline.relations.redacted);
const reactions = useObservableValue(timeline.relations.reactions.eventToRelations);
@ -484,6 +485,7 @@ export function RoomTimeline({ eventId, roomInputRef, editor, timeline }: RoomTi
{reactionJSX}
{threadTimeline && (
<ThreadSelector
active={threadTimeline.threadId === activeThread}
thread={threadTimeline}
hour24Clock={hour24Clock}
dateFormatString={dateFormatString}

View file

@ -1,6 +1,7 @@
import React from 'react';
import { Box, config, Icon, Icons, Line, Text } from 'folds';
import { Box, color, config, Icon, Icons, Line, Text } from 'folds';
import classNames from 'classnames';
import { useAtomValue } from 'jotai';
import * as css from './styles.css';
import { Time } from '../../../../components/message';
import { ThreadTimeline } from '../../../../../client/room/ThreadTimeline';
@ -15,8 +16,11 @@ import { UserAvatar } from '../../../../components/user-avatar';
import { useMediaAuthentication } from '../../../../hooks/useMediaAuthentication';
import { mxcToHttp } from '../../../../../client/mxcToHttp';
import { useClient } from '../../../../hooks/useClient';
import { composerToDraftAtom, getComposerId } from '../../../../state/room/roomInputDrafts';
import { toPlainText } from '../../../../components/editor';
type ThreadSelectorProps = {
active?: boolean;
thread: ThreadTimeline;
outlined?: boolean;
hour24Clock: boolean;
@ -27,6 +31,7 @@ type ThreadSelectorProps = {
};
export function ThreadSelector({
active,
thread,
outlined,
hour24Clock,
@ -38,6 +43,9 @@ export function ThreadSelector({
const ct = useClient();
const useAuthentication = useMediaAuthentication();
const composerId = getComposerId(thread.roomId, thread.threadId);
const draft = useAtomValue(composerToDraftAtom(composerId));
const meta = useObservableValue(thread.meta);
const latestReplyEvent = meta?.latestReplyEvent;
const participants = useThreadParticipants(thread);
@ -104,16 +112,23 @@ export function ThreadSelector({
</Box>
<Line className={css.ThreadSelectorDivider} direction="Vertical" variant="SurfaceVariant" />
<Box gap="200" alignItems="Inherit">
<Text size="T200" truncate>
<span>Last reply by </span>
<b>{getMemberName(latestReplyEvent.sender)}</b>
<span> at </span>
<Time
hour24Clock={hour24Clock}
dateFormatString={dateFormatString}
ts={latestReplyEvent.origin_server_ts}
/>
</Text>
{draft && !active ? (
<Text size="T200" truncate>
<strong style={{ color: color.Success.Main }}>Draft: </strong>
<span>{toPlainText(draft, false).trim()}</span>
</Text>
) : (
<Text size="T200" truncate>
<span>Last reply by </span>
<b>{getMemberName(latestReplyEvent.sender)}</b>
<span> at </span>
<Time
hour24Clock={hour24Clock}
dateFormatString={dateFormatString}
ts={latestReplyEvent.origin_server_ts}
/>
</Text>
)}
<Icon size="100" src={Icons.ChevronRight} />
</Box>
</Box>