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

View File

@@ -11,6 +11,7 @@ import { MatrixClient } from 'matrix-js-sdk';
import { getHomeRoomPath, getDirectRoomPath, getSpaceRoomPath } from './pages/pathUtils';
import { getCanonicalAliasOrRoomId, isRoomId } from './utils/matrix';
import { getCallService } from './features/call/useCall';
import { RoomType, StateEvent } from '../types/matrix/room';
/**
* Global reference to the router navigate function
@@ -23,6 +24,21 @@ let navigateFunction: ((path: string) => void) | null = null;
*/
let isInitialized = false;
/**
* @param {any} room
* @returns {boolean}
*/
function isSpaceLikeRoom(room: any): boolean {
if (!room) return false;
if (typeof room.isSpaceRoom === 'function' && room.isSpaceRoom()) return true;
const roomKindEvent = room.currentState?.getStateEvents?.(StateEvent.PaarrotRoomKind, '');
const roomKind = roomKindEvent?.getContent?.()?.kind;
if (roomKind === 'forum_space') return true;
const createEvent = room.currentState?.getStateEvents?.(StateEvent.RoomCreate, '');
const roomType = createEvent?.getContent?.()?.type;
return roomType === RoomType.Forum;
}
/**
* Set the navigate function for programmatic navigation
* Call this from your router setup
@@ -291,7 +307,7 @@ async function changeChannel(matrixClient: any, roomId: string) {
if (isDirect) {
// Navigate to direct message
path = getDirectRoomPath(roomIdOrAlias);
} else if (room.isSpaceRoom()) {
} else if (isSpaceLikeRoom(room)) {
// Navigate to space
path = getSpaceRoomPath(roomIdOrAlias, roomIdOrAlias);
} else {
@@ -316,7 +332,7 @@ async function getChannels(matrixClient: any) {
const rooms = matrixClient?.getRooms() || [];
return rooms
.filter((room: any) => !room.isSpaceRoom())
.filter((room: any) => !isSpaceLikeRoom(room))
.map((room: any) => {
// Extract server domain from roomId (!localpart:domain.tld)
const serverMatch = room.roomId.match(/:(.+)$/);