1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-11-20 16:22:28 +03:00

Make image reply rendering even more compact

This commit is contained in:
Tulir Asokan
2020-04-10 15:45:59 +03:00
parent 9b023fb37d
commit 25af26323c
4 changed files with 66 additions and 3 deletions

View File

@@ -1,5 +1,5 @@
/*
Copyright 2019 Tulir Asokan <tulir@maunium.net>
Copyright 2020 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.
@@ -14,7 +14,11 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import React from "react";
import { _td } from "../../../languageHandler";
import * as sdk from "../../../index";
import MImageBody from './MImageBody';
import MFileBody from "./MFileBody";
export default class MImageReplyBody extends MImageBody {
onClick(ev) {
@@ -27,6 +31,29 @@ export default class MImageReplyBody extends MImageBody {
// Don't show "Download this_file.png ..."
getFileBody() {
return null;
return MFileBody.prototype.presentableTextForFile.call(this, this.props.mxEvent.getContent());
}
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);
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')} />;
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>;
}
}

View File

@@ -184,7 +184,7 @@ class ReplyTile extends React.Component {
}
let sender;
const needsSenderProfile = tileHandler !== 'messages.RoomCreate' && !isInfoMessage;
const needsSenderProfile = msgtype !== 'm.image' && tileHandler !== 'messages.RoomCreate' && !isInfoMessage;
if (needsSenderProfile) {
let text = null;