From e949d91162de3c10cb079c2f4de7141231c99c1c Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Thu, 3 Nov 2016 16:39:20 +0000 Subject: [PATCH] Handle decryption errors --- src/components/views/messages/MImageBody.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/views/messages/MImageBody.js b/src/components/views/messages/MImageBody.js index 087a337bd2..c07051455e 100644 --- a/src/components/views/messages/MImageBody.js +++ b/src/components/views/messages/MImageBody.js @@ -92,9 +92,14 @@ module.exports = React.createClass({ this.dispatcherRef = dis.register(this.onAction); this.fixupHeight(); var content = this.props.mxEvent.getContent(); + var self = this; if (content.file !== undefined) { // TODO: hook up an error handler to the promise. - this.decryptFile(content.file); + this.decryptFile(content.file).catch(function (err) { + console.warn("Unable to decrypt attachment: ", err) + // Set a placeholder image when we can't decrypt the image. + self.refs.image.src = "img/warning.svg"; + }); } }, @@ -184,9 +189,10 @@ module.exports = React.createClass({ if (content.file !== undefined) { // Need to decrypt the attachment // The attachment is decrypted in componentDidMount. + // For now add an img tag with a spinner. return ( - {content.body} );