feat: filter to only include joined sub-rooms in Home and Space components
This commit is contained in:
@@ -287,9 +287,12 @@ export function Home() {
|
|||||||
const subRoomsEvent = room.currentState.getStateEvents(StateEvent.PaarrotSubRooms, '');
|
const subRoomsEvent = room.currentState.getStateEvents(StateEvent.PaarrotSubRooms, '');
|
||||||
const subRooms = subRoomsEvent?.getContent<{ children: string[] }>()?.children ?? [];
|
const subRooms = subRoomsEvent?.getContent<{ children: string[] }>()?.children ?? [];
|
||||||
|
|
||||||
|
// Filter to only joined sub-rooms
|
||||||
|
const joinedSubRooms = subRooms.filter(subRoomId => mx.getRoom(subRoomId));
|
||||||
|
|
||||||
// Add sub-rooms recursively
|
// Add sub-rooms recursively
|
||||||
subRooms.forEach((subRoomId, index) => {
|
joinedSubRooms.forEach((subRoomId, index) => {
|
||||||
addRoomAndSubRooms(subRoomId, depth + 1, roomId, index === subRooms.length - 1);
|
addRoomAndSubRooms(subRoomId, depth + 1, roomId, index === joinedSubRooms.length - 1);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -459,11 +459,15 @@ export function Space() {
|
|||||||
const subRoomsEvent = room.currentState.getStateEvents(StateEvent.PaarrotSubRooms, '');
|
const subRoomsEvent = room.currentState.getStateEvents(StateEvent.PaarrotSubRooms, '');
|
||||||
const subRooms = subRoomsEvent?.getContent<{ children: string[] }>()?.children ?? [];
|
const subRooms = subRoomsEvent?.getContent<{ children: string[] }>()?.children ?? [];
|
||||||
|
|
||||||
subRooms.forEach((subRoomId, index) => {
|
// Filter to only joined sub-rooms that haven't been processed
|
||||||
if (processedSubRooms.has(subRoomId)) return;
|
const joinedSubRooms = subRooms.filter(subRoomId =>
|
||||||
|
!processedSubRooms.has(subRoomId) && mx.getRoom(subRoomId)
|
||||||
|
);
|
||||||
|
|
||||||
|
joinedSubRooms.forEach((subRoomId, index) => {
|
||||||
processedSubRooms.add(subRoomId);
|
processedSubRooms.add(subRoomId);
|
||||||
|
|
||||||
const isLast = index === subRooms.length - 1;
|
const isLast = index === joinedSubRooms.length - 1;
|
||||||
const subRoom = mx.getRoom(subRoomId);
|
const subRoom = mx.getRoom(subRoomId);
|
||||||
if (subRoom) {
|
if (subRoom) {
|
||||||
// Joined sub-room
|
// Joined sub-room
|
||||||
|
|||||||
Reference in New Issue
Block a user