/* Copyright 2020-2021 Tulir Asokan 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 React from "react"; import { EventType } from "matrix-js-sdk/src/@types/event"; import MImageBody from "./MImageBody"; import { presentableTextForFile } from "../../../utils/FileUtils"; import { IMediaEventContent } from "../../../customisations/models/IMediaEventContent"; import SenderProfile from "./SenderProfile"; import { _t } from "../../../languageHandler"; const FORCED_IMAGE_HEIGHT = 44; export default class MImageReplyBody extends MImageBody { public onClick = (ev: React.MouseEvent): void => { ev.preventDefault(); }; public wrapImage(contentUrl: string, children: JSX.Element): JSX.Element { return children; } // Don't show "Download this_file.png ..." public getFileBody(): string { const sticker = this.props.mxEvent.getType() === EventType.Sticker; return presentableTextForFile(this.props.mxEvent.getContent(), sticker ? _t("Sticker") : _t("Image"), !sticker); } render() { if (this.state.error !== null) { return super.render(); } const content = this.props.mxEvent.getContent(); const contentUrl = this.getContentUrl(); const thumbnail = this.messageContent(contentUrl, this.getThumbUrl(), content, FORCED_IMAGE_HEIGHT); const fileBody = this.getFileBody(); const sender = ; return
{ thumbnail }
{ sender }
{ fileBody }
; } }