Files
ThreadNet-Web/src/components/views/rooms/ReplyPreview.tsx
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

55 lines
1.8 KiB
TypeScript
Raw Normal View History

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
2024-09-09 14:57:16 +01:00
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
Please see LICENSE files in the repository root for full details.
2017-12-10 12:50:41 +00:00
*/
import React from "react";
import { MatrixEvent } from "matrix-js-sdk/src/matrix";
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";
2021-06-29 13:11:58 +01:00
import { RoomPermalinkCreator } from "../../../utils/permalinks/Permalinks";
2021-07-13 08:45:36 +02:00
import ReplyTile from "./ReplyTile";
import RoomContext, { 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
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,
context,
2017-12-10 12:50:41 +00:00
});
}
2021-07-17 15:09:13 +02:00
interface IProps {
permalinkCreator?: RoomPermalinkCreator;
replyToEvent?: MatrixEvent;
2021-07-17 15:09:13 +02:00
}
export default class ReplyPreview extends React.Component<IProps> {
public static contextType = RoomContext;
2024-08-01 17:14:28 +01:00
public declare context: React.ContextType<typeof RoomContext>;
2019-03-01 09:36:36 +00:00
public render(): JSX.Element | null {
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">
<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)}
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>
);
}
}