feat: Implement forum feed layout and refactor space navigation logic to support new routing structure
This commit is contained in:
@@ -20,6 +20,7 @@ import {
|
||||
REGISTER_PATH,
|
||||
RESET_PASSWORD_PATH,
|
||||
ROOT_PATH,
|
||||
SPACE_FEED_PATH,
|
||||
SPACE_LOBBY_PATH,
|
||||
SPACE_PATH,
|
||||
SPACE_ROOM_PATH,
|
||||
@@ -28,6 +29,9 @@ import {
|
||||
} from './paths';
|
||||
import { trimLeadingSlash, trimTrailingSlash } from '../utils/common';
|
||||
import { HashRouterConfig } from '../hooks/useClientConfig';
|
||||
import type { MatrixClient } from 'matrix-js-sdk';
|
||||
import { getCanonicalAliasOrRoomId } from '../utils/matrix';
|
||||
import { shouldShowForumLobby } from '../utils/room';
|
||||
|
||||
export const joinPathComponent = (path: Path): string => path.pathname + path.search + path.hash;
|
||||
|
||||
@@ -128,6 +132,21 @@ export const getSpaceLobbyPath = (spaceIdOrAlias: string): string => {
|
||||
};
|
||||
return generatePath(SPACE_LOBBY_PATH, params);
|
||||
};
|
||||
export const getSpaceFeedPath = (spaceIdOrAlias: string): string => {
|
||||
const params = {
|
||||
spaceIdOrAlias: encodeURIComponent(spaceIdOrAlias),
|
||||
};
|
||||
return generatePath(SPACE_FEED_PATH, params);
|
||||
};
|
||||
/** Forum spaces open the post feed; other spaces open the lobby. */
|
||||
export const getSpaceDefaultPath = (mx: MatrixClient, spaceId: string): string => {
|
||||
const spaceIdOrAlias = getCanonicalAliasOrRoomId(mx, spaceId);
|
||||
const space = mx.getRoom(spaceId);
|
||||
if (space && shouldShowForumLobby(space)) {
|
||||
return getSpaceFeedPath(spaceIdOrAlias);
|
||||
}
|
||||
return getSpaceLobbyPath(spaceIdOrAlias);
|
||||
};
|
||||
export const getSpaceSearchPath = (spaceIdOrAlias: string): string => {
|
||||
const params = {
|
||||
spaceIdOrAlias: encodeURIComponent(spaceIdOrAlias),
|
||||
|
||||
Reference in New Issue
Block a user