feat: Implement forum feed layout and refactor space navigation logic to support new routing structure
This commit is contained in:
@@ -28,6 +28,10 @@ import { copyToClipboard } from '../../utils/dom';
|
||||
import { getCanonicalAliasOrRoomId, isRoomAlias } from '../../utils/matrix';
|
||||
import { getMatrixToRoom } from '../../plugins/matrix-to';
|
||||
import { getViaServers } from '../../plugins/via-servers';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { getSpaceFeedPath, getSpaceLobbyPath } from '../../pages/pathUtils';
|
||||
import { shouldShowForumLobby } from '../../utils/room';
|
||||
import { useSpaceFeedSelected } from '../../hooks/router/useSelectedSpace';
|
||||
|
||||
type ForumAddOptions = {
|
||||
item: HierarchyItem;
|
||||
@@ -50,6 +54,9 @@ type SpaceOptionsMenuProps = {
|
||||
export const SpaceOptionsMenu = forwardRef<HTMLDivElement, SpaceOptionsMenuProps>(
|
||||
({ room, requestClose, forumAdd, onOpenAddExisting }, ref) => {
|
||||
const mx = useMatrixClient();
|
||||
const navigate = useNavigate();
|
||||
const onFeed = useSpaceFeedSelected();
|
||||
const isForum = shouldShowForumLobby(room);
|
||||
const [hideActivity] = useSetting(settingsAtom, 'hideActivity');
|
||||
const [developerTools] = useSetting(settingsAtom, 'developerTools');
|
||||
const roomToParents = useAtomValue(roomToParentsAtom);
|
||||
@@ -101,6 +108,16 @@ export const SpaceOptionsMenu = forwardRef<HTMLDivElement, SpaceOptionsMenuProps
|
||||
requestClose();
|
||||
};
|
||||
|
||||
const handleOpenFeed = () => {
|
||||
navigate(getSpaceFeedPath(getCanonicalAliasOrRoomId(mx, room.roomId)));
|
||||
requestClose();
|
||||
};
|
||||
|
||||
const handleOpenManage = () => {
|
||||
navigate(getSpaceLobbyPath(getCanonicalAliasOrRoomId(mx, room.roomId)));
|
||||
requestClose();
|
||||
};
|
||||
|
||||
const handleAddTopic = () => {
|
||||
if (!forumAdd) return;
|
||||
openCreateRoomModal(forumAdd.item.roomId);
|
||||
@@ -200,6 +217,30 @@ export const SpaceOptionsMenu = forwardRef<HTMLDivElement, SpaceOptionsMenuProps
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{isForum && !onFeed && (
|
||||
<MenuItem
|
||||
onClick={handleOpenFeed}
|
||||
size="300"
|
||||
after={<Icon size="100" src={Icons.Thread} />}
|
||||
radii="300"
|
||||
>
|
||||
<Text style={{ flexGrow: 1 }} as="span" size="T300" truncate>
|
||||
Feed
|
||||
</Text>
|
||||
</MenuItem>
|
||||
)}
|
||||
{isForum && onFeed && (
|
||||
<MenuItem
|
||||
onClick={handleOpenManage}
|
||||
size="300"
|
||||
after={<Icon size="100" src={Icons.Flag} />}
|
||||
radii="300"
|
||||
>
|
||||
<Text style={{ flexGrow: 1 }} as="span" size="T300" truncate>
|
||||
Manage
|
||||
</Text>
|
||||
</MenuItem>
|
||||
)}
|
||||
<MenuItem
|
||||
onClick={handleMarkAsRead}
|
||||
size="300"
|
||||
|
||||
Reference in New Issue
Block a user