Merge pull request #6625 from matrix-org/palid/fix/media-isEncrypted-undefined

Fix error on accessing encrypted media without keys
This commit is contained in:
Dariusz Niemczyk 2021-08-18 15:17:55 +02:00 committed by GitHub
commit 1066bef1b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -178,7 +178,7 @@ export default class MFileBody extends React.Component<IProps, IState> {
private onPlaceholderClick = async () => { private onPlaceholderClick = async () => {
const mediaHelper = this.props.mediaEventHelper; const mediaHelper = this.props.mediaEventHelper;
if (mediaHelper.media.isEncrypted) { if (mediaHelper?.media.isEncrypted) {
await this.decryptFile(); await this.decryptFile();
this.downloadFile(this.fileName, this.linkText); this.downloadFile(this.fileName, this.linkText);
} else { } else {
@ -192,7 +192,7 @@ export default class MFileBody extends React.Component<IProps, IState> {
}; };
public render() { public render() {
const isEncrypted = this.props.mediaEventHelper.media.isEncrypted; const isEncrypted = this.props.mediaEventHelper?.media.isEncrypted;
const contentUrl = this.getContentUrl(); const contentUrl = this.getContentUrl();
const fileSize = this.content.info ? this.content.info.size : null; const fileSize = this.content.info ? this.content.info.size : null;
const fileType = this.content.info ? this.content.info.mimetype : "application/octet-stream"; const fileType = this.content.info ? this.content.info.mimetype : "application/octet-stream";