feat: add thread preview functionality to RoomNavItem component
This commit is contained in:
@@ -282,6 +282,20 @@ export function RoomNavItem({
|
||||
const roomToParents = useAtomValue(roomToParentsAtom);
|
||||
const mDirects = useAtomValue(mDirectAtom);
|
||||
|
||||
// Get first participated thread for preview
|
||||
const firstThreadPreview = (() => {
|
||||
const threads = room.getThreads();
|
||||
const participatedThreads = threads.filter((thread) => thread.hasCurrentUserParticipated);
|
||||
if (participatedThreads.length === 0) return undefined;
|
||||
|
||||
const firstThread = participatedThreads[0];
|
||||
const rootEvent = firstThread.rootEvent;
|
||||
if (!rootEvent) return undefined;
|
||||
|
||||
const rootBody = rootEvent.getContent()?.body ?? '';
|
||||
return rootBody;
|
||||
})();
|
||||
|
||||
// Get parent space for DMs
|
||||
const parentSpaceInfo = (() => {
|
||||
if (!direct || !mDirects.has(room.roomId)) return undefined;
|
||||
@@ -360,10 +374,15 @@ export function RoomNavItem({
|
||||
/>
|
||||
)}
|
||||
</Avatar>
|
||||
<Box as="span" grow="Yes">
|
||||
<Box as="span" grow="Yes" direction="Column" style={{ overflow: 'hidden', minWidth: 0 }}>
|
||||
<Text priority={unread ? '500' : '300'} as="span" size="Inherit" truncate>
|
||||
{room.name}
|
||||
</Text>
|
||||
{firstThreadPreview && (
|
||||
<Text as="span" size="T200" priority="300" truncate>
|
||||
╰ {firstThreadPreview}
|
||||
</Text>
|
||||
)}
|
||||
</Box>
|
||||
{!optionsVisible && !unread && !selected && typingMember.length > 0 && (
|
||||
<Badge size="300" variant="Secondary" fill="Soft" radii="Pill" outlined>
|
||||
|
||||
Reference in New Issue
Block a user