Remove redundant code and move presentableTextForFile out of MFileBody

Signed-off-by: Tulir Asokan <tulir@maunium.net>
This commit is contained in:
Tulir Asokan 2021-05-01 16:11:30 +03:00
parent 09f9916916
commit 330f222dd1
5 changed files with 55 additions and 140 deletions

View file

@ -1,5 +1,5 @@
/*
Copyright 2020 Tulir Asokan <tulir@maunium.net>
Copyright 2020-2021 Tulir Asokan <tulir@maunium.net>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -15,10 +15,10 @@ limitations under the License.
*/
import React from "react";
import { _td } from "../../../languageHandler";
import {_td} from "../../../languageHandler";
import * as sdk from "../../../index";
import MImageBody from './MImageBody';
import MFileBody from "./MFileBody";
import {presentableTextForFile} from "./MFileBody";
export default class MImageReplyBody extends MImageBody {
onClick(ev) {
@ -31,7 +31,7 @@ export default class MImageReplyBody extends MImageBody {
// Don't show "Download this_file.png ..."
getFileBody() {
return MFileBody.prototype.presentableTextForFile.call(this, this.props.mxEvent.getContent());
return presentableTextForFile(this.props.mxEvent.getContent());
}
render() {
@ -45,15 +45,17 @@ export default class MImageReplyBody extends MImageBody {
const thumbnail = this._messageContent(contentUrl, this._getThumbUrl(), content);
const fileBody = this.getFileBody();
const SenderProfile = sdk.getComponent('messages.SenderProfile');
const sender = <SenderProfile onClick={this.onSenderProfileClick}
mxEvent={this.props.mxEvent}
enableFlair={false}
text={_td('%(senderName)s sent an image')} />;
const sender = <SenderProfile
onClick={this.onSenderProfileClick}
mxEvent={this.props.mxEvent}
enableFlair={false}
text={_td('%(senderName)s sent an image')}
/>;
return <div className="mx_MImageReplyBody">
<div className="mx_MImageReplyBody_thumbnail">{ thumbnail }</div>
<div className="mx_MImageReplyBody_sender">{ sender }</div>
<div className="mx_MImageReplyBody_filename">{ fileBody }</div>
<div className="mx_MImageReplyBody_thumbnail">{thumbnail}</div>
<div className="mx_MImageReplyBody_sender">{sender}</div>
<div className="mx_MImageReplyBody_filename">{fileBody}</div>
</div>;
}
}