Add categorize spaces function in RoomList

Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
Ajay Bura 2022-03-02 20:57:29 +05:30
parent 6b03c9c99f
commit 094a11ec64

View file

@ -52,6 +52,28 @@ class RoomList extends EventEmitter {
return children?.filter((childId) => childId !== null);
}
getCategorizedSpaces(spaceIds) {
const categorized = new Map();
const categorizeSpace = (spaceId) => {
if (categorized.has(spaceId)) return;
const mappedChild = new Set();
categorized.set(spaceId, mappedChild);
const child = this.getSpaceChildren(spaceId);
child.forEach((childId) => {
const room = this.matrixClient.getRoom(childId);
if (room === null) return;
if (room.isSpaceRoom()) categorizeSpace(childId);
else mappedChild.add(childId);
});
};
spaceIds.map(categorizeSpace);
return categorized;
}
addToRoomIdToParents(roomId, parentRoomId) {
if (!this.roomIdToParents.has(roomId)) {
this.roomIdToParents.set(roomId, new Set());