2015-06-23 16:41:25 +01:00
|
|
|
/*
|
2024-09-09 14:57:16 +01:00
|
|
|
Copyright 2024 New Vector Ltd.
|
|
|
|
|
Copyright 2015-2021 The Matrix.org Foundation C.I.C.
|
2015-06-23 16:41:25 +01: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.
|
2015-06-23 16:41:25 +01:00
|
|
|
*/
|
|
|
|
|
|
2021-06-24 18:45:23 -04:00
|
|
|
import React from "react";
|
2023-08-07 09:24:58 +01:00
|
|
|
import { MatrixEvent } from "matrix-js-sdk/src/matrix";
|
2021-06-30 13:01:26 +01:00
|
|
|
|
2021-06-16 20:40:47 -04:00
|
|
|
import RoomContext from "../../../contexts/RoomContext";
|
2019-12-19 18:19:56 -07:00
|
|
|
import * as TextForEvent from "../../../TextForEvent";
|
2023-06-05 18:12:23 +01:00
|
|
|
import { MatrixClientPeg } from "../../../MatrixClientPeg";
|
2021-06-24 18:45:23 -04:00
|
|
|
|
|
|
|
|
interface IProps {
|
|
|
|
|
mxEvent: MatrixEvent;
|
|
|
|
|
}
|
2015-09-16 16:23:35 +01:00
|
|
|
|
2021-06-24 18:45:23 -04:00
|
|
|
export default class TextualEvent extends React.Component<IProps> {
|
2022-12-16 12:29:59 +00:00
|
|
|
public static contextType = RoomContext;
|
2024-08-05 08:59:27 +01:00
|
|
|
public declare context: React.ContextType<typeof RoomContext>;
|
2021-06-16 20:40:47 -04:00
|
|
|
|
2023-02-13 17:01:43 +00:00
|
|
|
public render(): React.ReactNode {
|
2023-06-05 18:12:23 +01:00
|
|
|
const text = TextForEvent.textForEvent(
|
|
|
|
|
this.props.mxEvent,
|
2023-06-15 08:46:19 +01:00
|
|
|
MatrixClientPeg.safeGet(),
|
2023-06-05 18:12:23 +01:00
|
|
|
true,
|
|
|
|
|
this.context?.showHiddenEvents,
|
|
|
|
|
);
|
2021-06-29 22:42:46 -04:00
|
|
|
if (!text) return null;
|
2021-06-24 18:45:23 -04:00
|
|
|
return <div className="mx_TextualEvent">{text}</div>;
|
2020-08-29 12:14:16 +01:00
|
|
|
}
|
|
|
|
|
}
|