mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-15 03:30:29 +03:00
show space header if subspaces contain rooms
This commit is contained in:
parent
ae75ee7fc3
commit
18082ff400
1 changed files with 24 additions and 1 deletions
|
|
@ -198,6 +198,29 @@ const getSpaceJoinedHierarchy = (
|
|||
new Set()
|
||||
);
|
||||
|
||||
/**
|
||||
* Recursively checks if the given space or any of its descendants contain non-space rooms.
|
||||
*
|
||||
* @param roomId - The space ID to check.
|
||||
* @returns True if the space or any descendant contains non-space rooms.
|
||||
*/
|
||||
const containsRoom = (spaceId: string) => {
|
||||
const space = getRoom(spaceId);
|
||||
if (!space) return false;
|
||||
|
||||
const childEvents = getStateEvents(space, StateEvent.SpaceChild).filter(isValidChild);
|
||||
|
||||
return childEvents.some((childEvent): boolean => {
|
||||
const childId = childEvent.getStateKey();
|
||||
if (!childId || !isRoomId(childId)) return false;
|
||||
const room = getRoom(childId);
|
||||
if (!room) return false;
|
||||
|
||||
if (!room.isSpaceRoom()) return true;
|
||||
return containsRoom(childId);
|
||||
});
|
||||
};
|
||||
|
||||
const hierarchy: HierarchyItem[] = spaceItems.flatMap((spaceItem) => {
|
||||
const space = getRoom(spaceItem.roomId);
|
||||
if (!space) {
|
||||
|
|
@ -213,7 +236,7 @@ const getSpaceJoinedHierarchy = (
|
|||
return true;
|
||||
});
|
||||
|
||||
if (joinedRoomEvents.length === 0) return [];
|
||||
if (!containsRoom(spaceItem.roomId)) return [];
|
||||
|
||||
const childItems: HierarchyItemRoom[] = [];
|
||||
joinedRoomEvents.forEach((childEvent) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue