mirror of
https://github.com/element-hq/element-web
synced 2024-11-22 01:05:42 +03:00
Step 8.5: Move forward dialog construction
This commit is contained in:
parent
51f90a1a73
commit
8dab169c52
4 changed files with 49 additions and 4 deletions
|
@ -33,7 +33,6 @@ import { isUrlPermitted } from '../../../HtmlUtils';
|
|||
import { isContentActionable } from '../../../utils/EventUtils';
|
||||
import IconizedContextMenu, { IconizedContextMenuOption, IconizedContextMenuOptionList } from './IconizedContextMenu';
|
||||
import { ReadPinsEventId } from "../right_panel/types";
|
||||
import ForwardDialog from "../dialogs/ForwardDialog";
|
||||
import { Action } from "../../../dispatcher/actions";
|
||||
import ReportEventDialog from '../dialogs/ReportEventDialog';
|
||||
import ViewSource from '../../structures/ViewSource';
|
||||
|
@ -47,6 +46,7 @@ import { WidgetLayoutStore } from '../../../stores/widgets/WidgetLayoutStore';
|
|||
import EndPollDialog from '../dialogs/EndPollDialog';
|
||||
import { isPollEnded } from '../messages/MPollBody';
|
||||
import { ViewRoomPayload } from "../../../dispatcher/payloads/ViewRoomPayload";
|
||||
import { OpenForwardDialogPayload } from "../../../dispatcher/payloads/OpenForwardDialogPayload";
|
||||
import { createMapSiteLink } from '../../../utils/location';
|
||||
|
||||
export function canCancel(status: EventStatus): boolean {
|
||||
|
@ -177,11 +177,11 @@ export default class MessageContextMenu extends React.Component<IProps, IState>
|
|||
};
|
||||
|
||||
private onForwardClick = (): void => {
|
||||
Modal.createTrackedDialog('Forward Message', '', ForwardDialog, {
|
||||
matrixClient: MatrixClientPeg.get(),
|
||||
dis.dispatch({
|
||||
action: Action.OpenForwardDialog,
|
||||
event: this.props.mxEvent,
|
||||
permalinkCreator: this.props.permalinkCreator,
|
||||
});
|
||||
} as OpenForwardDialogPayload);
|
||||
this.closeMenu();
|
||||
};
|
||||
|
||||
|
|
|
@ -265,4 +265,10 @@ export enum Action {
|
|||
* Payload: ActiveRoomChangedPayload
|
||||
*/
|
||||
ActiveRoomChanged = "active_room_changed",
|
||||
|
||||
/**
|
||||
* Fired when the forward dialog needs to be opened.
|
||||
* Payload: OpenForwardDialogPayload
|
||||
*/
|
||||
OpenForwardDialog = "open_forward_dialog",
|
||||
}
|
||||
|
|
29
src/dispatcher/payloads/OpenForwardDialogPayload.ts
Normal file
29
src/dispatcher/payloads/OpenForwardDialogPayload.ts
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
Copyright 2022 The Matrix.org Foundation C.I.C.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
||||
import { Optional } from "matrix-events-sdk";
|
||||
|
||||
import { Action } from "../actions";
|
||||
import { ActionPayload } from "../payloads";
|
||||
import { RoomPermalinkCreator } from "../../utils/permalinks/Permalinks";
|
||||
|
||||
export interface OpenForwardDialogPayload extends ActionPayload {
|
||||
action: Action.OpenForwardDialog;
|
||||
|
||||
event: MatrixEvent;
|
||||
permalinkCreator: Optional<RoomPermalinkCreator>;
|
||||
}
|
|
@ -19,6 +19,9 @@ import { ActionPayload } from "../dispatcher/payloads";
|
|||
import Modal from "../Modal";
|
||||
import RoomSettingsDialog from "../components/views/dialogs/RoomSettingsDialog";
|
||||
import { RoomViewStore } from "../stores/RoomViewStore";
|
||||
import ForwardDialog from "../components/views/dialogs/ForwardDialog";
|
||||
import { MatrixClientPeg } from "../MatrixClientPeg";
|
||||
import { Action } from "../dispatcher/actions";
|
||||
|
||||
/**
|
||||
* Auxiliary class to listen for dialog opening over the dispatcher and
|
||||
|
@ -49,6 +52,13 @@ export class DialogOpener {
|
|||
initialTabId: payload.initial_tab_id,
|
||||
}, /*className=*/null, /*isPriority=*/false, /*isStatic=*/true);
|
||||
break;
|
||||
case Action.OpenForwardDialog:
|
||||
Modal.createTrackedDialog('Forward Message', '', ForwardDialog, {
|
||||
matrixClient: MatrixClientPeg.get(),
|
||||
event: payload.event,
|
||||
permalinkCreator: payload.permalinkCreator,
|
||||
});
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue