2017-12-10 12:50:41 +00:00
|
|
|
/*
|
2024-09-09 14:57:16 +01:00
|
|
|
Copyright 2024 New Vector Ltd.
|
|
|
|
|
Copyright 2017-2021 The Matrix.org Foundation C.I.C.
|
2017-12-10 12:50:41 +00:00
|
|
|
|
2025-01-06 11:18:54 +00:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
2024-09-09 14:57:16 +01:00
|
|
|
Please see LICENSE files in the repository root for full details.
|
2017-12-10 12:50:41 +00:00
|
|
|
*/
|
|
|
|
|
|
2025-03-27 10:43:58 +00:00
|
|
|
import React, { type JSX } from "react";
|
2025-02-05 13:25:06 +00:00
|
|
|
import { type MatrixEvent } from "matrix-js-sdk/src/matrix";
|
2025-12-15 09:52:50 +00:00
|
|
|
import { CloseIcon } from "@vector-im/compound-design-tokens/assets/web/icons";
|
2021-10-22 17:23:32 -05:00
|
|
|
|
2020-05-13 20:41:41 -06:00
|
|
|
import dis from "../../../dispatcher/dispatcher";
|
2017-12-15 17:57:24 +00:00
|
|
|
import { _t } from "../../../languageHandler";
|
2025-02-05 13:25:06 +00:00
|
|
|
import { type RoomPermalinkCreator } from "../../../utils/permalinks/Permalinks";
|
2021-07-13 08:45:36 +02:00
|
|
|
import ReplyTile from "./ReplyTile";
|
2025-02-05 13:25:06 +00:00
|
|
|
import RoomContext, { type TimelineRenderingType } from "../../../contexts/RoomContext";
|
2022-06-27 09:43:58 +01:00
|
|
|
import AccessibleButton from "../elements/AccessibleButton";
|
2017-12-10 12:50:41 +00:00
|
|
|
|
2023-01-12 13:25:14 +00:00
|
|
|
function cancelQuoting(context: TimelineRenderingType): void {
|
2017-12-10 12:50:41 +00:00
|
|
|
dis.dispatch({
|
2018-02-19 23:41:07 +00:00
|
|
|
action: "reply_to_event",
|
2017-12-10 12:50:41 +00:00
|
|
|
event: null,
|
2021-10-19 16:05:34 +01:00
|
|
|
context,
|
2017-12-10 12:50:41 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-17 15:09:13 +02:00
|
|
|
interface IProps {
|
2023-04-13 08:52:57 +01:00
|
|
|
permalinkCreator?: RoomPermalinkCreator;
|
2022-09-16 11:10:33 +02:00
|
|
|
replyToEvent?: MatrixEvent;
|
2021-07-17 15:09:13 +02:00
|
|
|
}
|
|
|
|
|
|
2021-10-19 16:05:34 +01:00
|
|
|
export default class ReplyPreview extends React.Component<IProps> {
|
|
|
|
|
public static contextType = RoomContext;
|
2024-12-02 09:39:36 +00:00
|
|
|
declare public context: React.ContextType<typeof RoomContext>;
|
2019-03-01 09:36:36 +00:00
|
|
|
|
2022-09-16 11:10:33 +02:00
|
|
|
public render(): JSX.Element | null {
|
2021-10-19 16:05:34 +01:00
|
|
|
if (!this.props.replyToEvent) return null;
|
2017-12-10 12:50:41 +00:00
|
|
|
|
2018-02-10 12:38:25 +00:00
|
|
|
return (
|
|
|
|
|
<div className="mx_ReplyPreview">
|
2022-06-27 09:43:58 +01:00
|
|
|
<div className="mx_ReplyPreview_section">
|
|
|
|
|
<div className="mx_ReplyPreview_header">
|
2023-09-27 17:15:22 +01:00
|
|
|
<span>{_t("composer|replying_title")}</span>
|
2022-06-27 09:43:58 +01:00
|
|
|
<AccessibleButton
|
|
|
|
|
className="mx_ReplyPreview_header_cancel"
|
|
|
|
|
onClick={() => cancelQuoting(this.context.timelineRenderingType)}
|
2025-12-15 09:52:50 +00:00
|
|
|
>
|
|
|
|
|
<CloseIcon />
|
|
|
|
|
</AccessibleButton>
|
2022-12-12 12:24:14 +01:00
|
|
|
</div>
|
2022-06-27 09:43:58 +01:00
|
|
|
<ReplyTile mxEvent={this.props.replyToEvent} permalinkCreator={this.props.permalinkCreator} />
|
|
|
|
|
</div>
|
2017-12-10 12:50:41 +00:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|