Handle non-media attachments

This commit is contained in:
Jaiwanth 2021-05-31 23:50:55 +05:30
parent 01284ef8c6
commit a0a604618c
3 changed files with 18 additions and 2 deletions

View file

@ -102,6 +102,8 @@ export default class MFileBody extends React.Component {
tileShape: PropTypes.string, tileShape: PropTypes.string,
/* whether or not to show the default placeholder for the file. Defaults to true. */ /* whether or not to show the default placeholder for the file. Defaults to true. */
showGenericPlaceholder: PropTypes.bool, showGenericPlaceholder: PropTypes.bool,
/* to set source to local file path during export */
mediaSrc: PropTypes.string,
}; };
static defaultProps = { static defaultProps = {
@ -178,7 +180,13 @@ export default class MFileBody extends React.Component {
); );
} }
if (isEncrypted) { if (this.props.mediaSrc) {
return <span className="mx_MFileBody">
<a href={this.props.mediaSrc}>
{ placeholder }
</a>
</span>;
} else if (isEncrypted) {
if (this.state.decryptedBlob === null) { if (this.state.decryptedBlob === null) {
// Need to decrypt the attachment // Need to decrypt the attachment
// Wait for the user to click on the link before downloading // Wait for the user to click on the link before downloading

View file

@ -936,7 +936,7 @@ export default class EventTile extends React.Component<IProps, IState> {
avatar = ( avatar = (
<div className="mx_EventTile_avatar"> <div className="mx_EventTile_avatar">
<MemberAvatar <MemberAvatar
avatarSrc = {this.props.avatarSrc} avatarSrc={this.props.avatarSrc}
member={member} member={member}
width={avatarSize} width={avatarSize}
height={avatarSize} height={avatarSize}

View file

@ -236,6 +236,14 @@ export default class HTMLExporter extends Exporter {
this.zip.file(filePath, blob); this.zip.file(filePath, blob);
break; break;
} }
case "m.file": {
const blob = await this.getMediaBlob(mxEv);
const fileName = mxEv.getContent().body;
const filePath = `files/${fileName}`;
eventTile = this.getEventTile(mxEv, joined, filePath);
this.zip.file(filePath, blob);
break;
}
default: default:
eventTile = this.getEventTile(mxEv, joined); eventTile = this.getEventTile(mxEv, joined);
break; break;