From: Ajay Bura Date: Wed, 2 Mar 2022 15:27:29 +0000 (+0530) Subject: Add categorize spaces function in RoomList X-Git-Tag: v1.8.0~28 X-Git-Url: https://git.wafflesoft.org/?a=commitdiff_plain;h=094a11ec648acd98944ea50956c4c564b4dce76b;p=cinny.git Add categorize spaces function in RoomList Signed-off-by: Ajay Bura --- diff --git a/src/client/state/RoomList.js b/src/client/state/RoomList.js index 263c454..bd38155 100644 --- a/src/client/state/RoomList.js +++ b/src/client/state/RoomList.js @@ -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());