From bbcf2fea53d81cb344e36e21221c298be46e30d5 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Fri, 18 May 2018 09:47:49 +0100 Subject: [PATCH] Fix e2e image thumbnail spinner containing box correct size --- src/components/views/messages/MImageBody.js | 55 ++++++++++----------- 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/src/components/views/messages/MImageBody.js b/src/components/views/messages/MImageBody.js index 87fe8d906c..f1454d1ac5 100644 --- a/src/components/views/messages/MImageBody.js +++ b/src/components/views/messages/MImageBody.js @@ -232,7 +232,29 @@ export default class extends React.Component { _messageContent(contentUrl, thumbUrl, content) { const maxHeight = Math.min(THUMBNAIL_MAX_HEIGHT, content.info.h); const maxWidth = content.info.w * maxHeight / content.info.h; - const thumbnail = ( + + let img = null; + // e2e image hasn't been decrypted yet + if (content.file !== undefined && this.state.decryptedUrl === null) { + img =
+ {content.body} +
; + } else if (thumbUrl && !this.state.imgError) { + img = {content.body}; + } + const thumbnail = img ?
{ /* Calculate aspect ratio, using %padding will size _container correctly */ } @@ -240,20 +262,13 @@ export default class extends React.Component { { /* Thumbnail CSS class resizes to exactly container size with inline CSS to restrict width */ } - {content.body} + { img }
-
- ); + : null; return ( - { thumbUrl && !this.state.imgError ? thumbnail : '' } + { thumbnail } ); @@ -271,24 +286,6 @@ export default class extends React.Component { ); } - if (content.file !== undefined && this.state.decryptedUrl === null) { - // Need to decrypt the attachment - // The attachment is decrypted in componentDidMount. - // For now add an img tag with a spinner. - return ( - -
- {content.body} -
-
- ); - } const contentUrl = this._getContentUrl(); let thumbUrl;