Merge pull request #6829 from matrix-org/t3chguy/fix/18969

This commit is contained in:
Michael Telatynski 2021-10-14 09:59:34 +01:00 committed by GitHub
commit 4118d13846
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 526 additions and 209 deletions

View file

@ -155,20 +155,28 @@ export const showCreateNewSubspace = (space: Room): void => {
);
};
export const bulkSpaceBehaviour = async (
space: Room,
children: Room[],
fn: (room: Room) => Promise<unknown>,
): Promise<void> => {
const modal = Modal.createDialog(Spinner, null, "mx_Dialog_spinner");
try {
for (const room of children) {
await fn(room);
}
await fn(space);
} finally {
modal.close();
}
};
export const leaveSpace = (space: Room) => {
Modal.createTrackedDialog("Leave Space", "", LeaveSpaceDialog, {
space,
onFinished: async (leave: boolean, rooms: Room[]) => {
if (!leave) return;
const modal = Modal.createDialog(Spinner, null, "mx_Dialog_spinner");
try {
for (const room of rooms) {
await leaveRoomBehaviour(room.roomId);
}
await leaveRoomBehaviour(space.roomId);
} finally {
modal.close();
}
await bulkSpaceBehaviour(space, rooms, room => leaveRoomBehaviour(room.roomId));
dis.dispatch({
action: "after_leave_room",