Properly recurse subspaces for leave space dialog options (#7775)

pull/21833/head
Michael Telatynski 2022-02-10 13:11:28 +00:00 committed by GitHub
parent fd832488f1
commit 7668984ee4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -41,7 +41,14 @@ const isOnlyAdmin = (room: Room): boolean => {
};
const LeaveSpaceDialog: React.FC<IProps> = ({ 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<Room[]>([]);
const selectedRooms = useMemo(() => new Set(roomsToLeave), [roomsToLeave]);