Allow options to cascade kicks/bans throughout spaces
This commit is contained in:
parent
cf8100ad17
commit
1858c63c4a
12 changed files with 481 additions and 177 deletions
|
@ -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",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue