Fix space hierarchy not updating when user mutates it
This commit is contained in:
parent
5d9e421de0
commit
ed950875e7
5 changed files with 57 additions and 42 deletions
|
@ -30,6 +30,9 @@ import InfoDialog from "../components/views/dialogs/InfoDialog";
|
|||
import { showRoomInviteDialog } from "../RoomInvite";
|
||||
import CreateSubspaceDialog from "../components/views/dialogs/CreateSubspaceDialog";
|
||||
import AddExistingSubspaceDialog from "../components/views/dialogs/AddExistingSubspaceDialog";
|
||||
import defaultDispatcher from "../dispatcher/dispatcher";
|
||||
import RoomViewStore from "../stores/RoomViewStore";
|
||||
import { Action } from "../dispatcher/actions";
|
||||
|
||||
export const shouldShowSpaceSettings = (space: Room) => {
|
||||
const userId = space.client.getUserId();
|
||||
|
@ -56,8 +59,8 @@ export const showSpaceSettings = (space: Room) => {
|
|||
}, /*className=*/null, /*isPriority=*/false, /*isStatic=*/true);
|
||||
};
|
||||
|
||||
export const showAddExistingRooms = async (space: Room): Promise<[boolean]> => {
|
||||
return Modal.createTrackedDialog(
|
||||
export const showAddExistingRooms = (space: Room): void => {
|
||||
Modal.createTrackedDialog(
|
||||
"Space Landing",
|
||||
"Add Existing",
|
||||
AddExistingToSpaceDialog,
|
||||
|
@ -65,12 +68,17 @@ export const showAddExistingRooms = async (space: Room): Promise<[boolean]> => {
|
|||
onCreateRoomClick: () => showCreateNewRoom(space),
|
||||
onAddSubspaceClick: () => showAddExistingSubspace(space),
|
||||
space,
|
||||
onFinished: (added: boolean) => {
|
||||
if (added && RoomViewStore.getRoomId() === space.roomId) {
|
||||
defaultDispatcher.fire(Action.UpdateSpaceHierarchy);
|
||||
}
|
||||
},
|
||||
},
|
||||
"mx_AddExistingToSpaceDialog_wrapper",
|
||||
).finished as Promise<[boolean]>;
|
||||
);
|
||||
};
|
||||
|
||||
export const showCreateNewRoom = async (space: Room) => {
|
||||
export const showCreateNewRoom = async (space: Room): Promise<boolean> => {
|
||||
const modal = Modal.createTrackedDialog<[boolean, IOpts]>(
|
||||
"Space Landing",
|
||||
"Create Room",
|
||||
|
@ -87,7 +95,7 @@ export const showCreateNewRoom = async (space: Room) => {
|
|||
return shouldCreate;
|
||||
};
|
||||
|
||||
export const showSpaceInvite = (space: Room, initialText = "") => {
|
||||
export const showSpaceInvite = (space: Room, initialText = ""): void => {
|
||||
if (space.getJoinRule() === "public") {
|
||||
const modal = Modal.createTrackedDialog("Space Invite", "User Menu", InfoDialog, {
|
||||
title: _t("Invite to %(spaceName)s", { spaceName: space.name }),
|
||||
|
@ -105,28 +113,38 @@ export const showSpaceInvite = (space: Room, initialText = "") => {
|
|||
}
|
||||
};
|
||||
|
||||
export const showAddExistingSubspace = async (space: Room): Promise<[boolean]> => {
|
||||
return Modal.createTrackedDialog(
|
||||
export const showAddExistingSubspace = (space: Room): void => {
|
||||
Modal.createTrackedDialog(
|
||||
"Space Landing",
|
||||
"Create Subspace",
|
||||
AddExistingSubspaceDialog,
|
||||
{
|
||||
space,
|
||||
onCreateSubspaceClick: () => showCreateNewSubspace(space),
|
||||
onFinished: (added: boolean) => {
|
||||
if (added && RoomViewStore.getRoomId() === space.roomId) {
|
||||
defaultDispatcher.fire(Action.UpdateSpaceHierarchy);
|
||||
}
|
||||
},
|
||||
},
|
||||
"mx_AddExistingToSpaceDialog_wrapper",
|
||||
).finished as Promise<[boolean]>;
|
||||
);
|
||||
};
|
||||
|
||||
export const showCreateNewSubspace = async (space: Room): Promise<[boolean]> => {
|
||||
return Modal.createTrackedDialog(
|
||||
export const showCreateNewSubspace = (space: Room): void => {
|
||||
Modal.createTrackedDialog(
|
||||
"Space Landing",
|
||||
"Create Subspace",
|
||||
CreateSubspaceDialog,
|
||||
{
|
||||
space,
|
||||
onAddExistingSpaceClick: () => showAddExistingSubspace(space),
|
||||
onFinished: (added: boolean) => {
|
||||
if (added && RoomViewStore.getRoomId() === space.roomId) {
|
||||
defaultDispatcher.fire(Action.UpdateSpaceHierarchy);
|
||||
}
|
||||
},
|
||||
},
|
||||
"mx_CreateSubspaceDialog_wrapper",
|
||||
).finished as Promise<[boolean]>;
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue