Convert MImageReplyBody to TS

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
pull/21833/head
Šimon Brandner 2021-07-02 14:17:40 +02:00
parent 5d78eb4a75
commit 6645036780
No known key found for this signature in database
GPG Key ID: 9760693FDD98A790
2 changed files with 15 additions and 14 deletions

View File

@ -15,22 +15,26 @@ limitations under the License.
*/ */
import React from "react"; import React from "react";
import { _td } from "../../../languageHandler"; import MImageBody, { IProps as MImageBodyIProps } from "./MImageBody";
import * as sdk from "../../../index";
import MImageBody from './MImageBody';
import { presentableTextForFile } from "./MFileBody"; import { presentableTextForFile } from "./MFileBody";
import { IMediaEventContent } from "../../../customisations/models/IMediaEventContent";
import SenderProfile from "./SenderProfile";
export default class MImageReplyBody extends MImageBody { export default class MImageReplyBody extends MImageBody {
onClick(ev) { constructor(props: MImageBodyIProps) {
ev.preventDefault(); super(props);
} }
wrapImage(contentUrl, children) { public onClick = (ev: React.MouseEvent): void => {
ev.preventDefault();
};
public wrapImage(contentUrl: string, children: JSX.Element): JSX.Element {
return children; return children;
} }
// Don't show "Download this_file.png ..." // Don't show "Download this_file.png ..."
getFileBody() { public getFileBody(): JSX.Element {
return presentableTextForFile(this.props.mxEvent.getContent()); return presentableTextForFile(this.props.mxEvent.getContent());
} }
@ -39,17 +43,14 @@ export default class MImageReplyBody extends MImageBody {
return super.render(); return super.render();
} }
const content = this.props.mxEvent.getContent(); const content = this.props.mxEvent.getContent() as IMediaEventContent;
const contentUrl = this._getContentUrl(); const contentUrl = this.getContentUrl();
const thumbnail = this._messageContent(contentUrl, this._getThumbUrl(), content); const thumbnail = this.messageContent(contentUrl, this.getThumbUrl(), content);
const fileBody = this.getFileBody(); const fileBody = this.getFileBody();
const SenderProfile = sdk.getComponent('messages.SenderProfile');
const sender = <SenderProfile const sender = <SenderProfile
onClick={this.onSenderProfileClick}
mxEvent={this.props.mxEvent} mxEvent={this.props.mxEvent}
enableFlair={false} enableFlair={false}
text={_td('%(senderName)s sent an image')}
/>; />;
return <div className="mx_MImageReplyBody"> return <div className="mx_MImageReplyBody">

View File

@ -24,7 +24,7 @@ import { MatrixEvent } from "matrix-js-sdk/src/models/event";
interface IProps { interface IProps {
mxEvent: MatrixEvent; mxEvent: MatrixEvent;
onClick(): void; onClick?(): void;
enableFlair: boolean; enableFlair: boolean;
} }