Files
ThreadNet-Web/apps/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.

58 lines
2.1 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
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
*/
import React, { type JSX } from "react";
2025-02-05 13:25:06 +00:00
import { type MatrixEvent } from "matrix-js-sdk/src/matrix";
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
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-12-02 09:39:36 +00:00
declare public 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)}
>
<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>
);
}
}