From 7668984ee454d11e78f17be6a843ff03748284fc Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 10 Feb 2022 13:11:28 +0000 Subject: [PATCH] Properly recurse subspaces for leave space dialog options (#7775) --- src/components/views/dialogs/LeaveSpaceDialog.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/views/dialogs/LeaveSpaceDialog.tsx b/src/components/views/dialogs/LeaveSpaceDialog.tsx index 74fec7eae2..804987f53a 100644 --- a/src/components/views/dialogs/LeaveSpaceDialog.tsx +++ b/src/components/views/dialogs/LeaveSpaceDialog.tsx @@ -41,7 +41,14 @@ const isOnlyAdmin = (room: Room): boolean => { }; const LeaveSpaceDialog: React.FC = ({ space, onFinished }) => { - const spaceChildren = useMemo(() => SpaceStore.instance.getChildren(space.roomId), [space.roomId]); + const spaceChildren = useMemo(() => { + const roomSet = new Set(SpaceStore.instance.getSpaceFilteredRoomIds(space.roomId)); + SpaceStore.instance.traverseSpace(space.roomId, spaceId => { + if (space.roomId === spaceId) return; // skip the root node + roomSet.add(spaceId); + }, false); + return Array.from(roomSet).map(roomId => space.client.getRoom(roomId)).filter(Boolean); + }, [space]); const [roomsToLeave, setRoomsToLeave] = useState([]); const selectedRooms = useMemo(() => new Set(roomsToLeave), [roomsToLeave]);