feat: Integrate forum layout support across various components and enhance room handling logic

This commit is contained in:
2026-07-06 01:06:20 +10:00
parent d1626e3585
commit c57797ffe4
62 changed files with 6876 additions and 385 deletions
@@ -0,0 +1,93 @@
import React, { useEffect, useRef } from 'react';
import { Box, Icon, Icons, Text } from 'folds';
import { useSetAtom } from 'jotai';
import { Page, PageContent } from '../../components/page';
import { useMatrixClient } from '../../hooks/useMatrixClient';
import { PowerLevelsContextProvider, usePowerLevels } from '../../hooks/usePowerLevels';
import { ThreadView } from '../room/ThreadView';
import { RoomInput } from '../room/RoomInput';
import { useEditor } from '../../components/editor';
import { activeThreadIdAtomFamily } from '../../state/activeThread';
import { useForumBoardContext } from './ForumBoardContext';
import * as css from './ForumBoardView.css';
/** Thread detail + composer (main pane); post list lives in ForumFeedSidebar. */
export function ForumBoardDetail() {
const mx = useMatrixClient();
const editor = useEditor();
const detailScrollRef = useRef<HTMLDivElement>(null);
const {
forumSpace,
query,
selectedPostId,
activeTopicRoomId,
error,
} = useForumBoardContext();
const activeTopicRoom = activeTopicRoomId ? mx.getRoom(activeTopicRoomId) : null;
const topicPowerLevels = usePowerLevels(activeTopicRoom ?? forumSpace);
const setActiveThreadId = useSetAtom(
activeThreadIdAtomFamily(activeTopicRoomId ?? forumSpace.roomId)
);
const topicSelected = Boolean(query.topic);
useEffect(() => {
if (selectedPostId && activeTopicRoomId) {
setActiveThreadId(selectedPostId);
return () => setActiveThreadId(undefined);
}
setActiveThreadId(undefined);
return undefined;
}, [selectedPostId, activeTopicRoomId, setActiveThreadId]);
const showComposer = Boolean(activeTopicRoom && topicSelected);
return (
<Page>
<PageContent>
<Box className={css.ForumDetailOnlyRoot}>
{error && (
<Box style={{ padding: '0.5rem 1rem' }}>
<Text style={{ color: 'var(--fc-critical, #f38ba8)' }}>{error}</Text>
</Box>
)}
<Box ref={detailScrollRef} className={css.ForumDetailPanelFull}>
{selectedPostId && activeTopicRoom ? (
<PowerLevelsContextProvider value={topicPowerLevels}>
<ThreadView room={activeTopicRoom} threadRootId={selectedPostId} />
</PowerLevelsContextProvider>
) : (
<Box grow="Yes" alignItems="Center" justifyContent="Center" direction="Column" gap="200">
<Icon src={Icons.Thread} size="600" />
<Text priority="300">
{topicSelected
? 'Select a post from the list'
: 'Choose a topic in the sidebar'}
</Text>
</Box>
)}
{showComposer && activeTopicRoom && (
<Box
shrink="No"
direction="Column"
style={{ padding: '0.75rem', borderTop: '1px solid var(--fc-surface-container)' }}
>
<PowerLevelsContextProvider value={topicPowerLevels}>
<RoomInput
room={activeTopicRoom}
editor={editor}
roomId={activeTopicRoom.roomId}
fileDropContainerRef={detailScrollRef}
/>
</PowerLevelsContextProvider>
</Box>
)}
</Box>
</Box>
</PageContent>
</Page>
);
}