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

@@ -5,7 +5,7 @@ import { mDirectAtom } from '../../../state/mDirectList';
import { roomToParentsAtom } from '../../../state/room/roomToParents';
import { allRoomsAtom } from '../../../state/room-list/roomList';
import { useOrphanRooms } from '../../../state/hooks/roomList';
import { StateEvent } from '../../../../types/matrix/room';
import { RoomType, StateEvent } from '../../../../types/matrix/room';
export const useHomeRooms = () => {
const mx = useMatrixClient();
@@ -15,6 +15,25 @@ export const useHomeRooms = () => {
// Filter out rooms that are sub-rooms of ANY room (not just orphan rooms)
const rooms = useMemo(() => {
const isSpaceLikeRoom = (roomId: string): boolean => {
const room = mx.getRoom(roomId);
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?: string }>()?.kind;
if (roomKind === 'forum_space') {
return true;
}
const createEvent = room.currentState.getStateEvents(StateEvent.RoomCreate, '');
const roomType = createEvent?.getContent<{ type?: string }>()?.type;
return roomType === RoomType.Space || roomType === RoomType.Forum;
};
// Build a set of all sub-room IDs from ALL joined rooms
const allSubRoomIds = new Set<string>();
mx.getRooms().forEach((room) => {
@@ -24,7 +43,7 @@ export const useHomeRooms = () => {
});
// Return only rooms that are not sub-rooms of another room
return orphanRooms.filter((roomId) => !allSubRoomIds.has(roomId));
return orphanRooms.filter((roomId) => !allSubRoomIds.has(roomId) && !isSpaceLikeRoom(roomId));
}, [mx, orphanRooms]);
return rooms;