Add categorize spaces function in RoomList
Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
parent
6b03c9c99f
commit
094a11ec64
1 changed files with 22 additions and 0 deletions
|
@ -52,6 +52,28 @@ class RoomList extends EventEmitter {
|
||||||
return children?.filter((childId) => childId !== null);
|
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) {
|
addToRoomIdToParents(roomId, parentRoomId) {
|
||||||
if (!this.roomIdToParents.has(roomId)) {
|
if (!this.roomIdToParents.has(roomId)) {
|
||||||
this.roomIdToParents.set(roomId, new Set());
|
this.roomIdToParents.set(roomId, new Set());
|
||||||
|
|
Loading…
Reference in a new issue