1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-11-05 23:10:41 +03:00

correctly fix up thumbnail height onload.

fixes https://github.com/vector-im/riot-web/issues/6492, although popping is inevitable in
the current implementation as it only fixes up the thumbnail size once the image has loaded.
This commit is contained in:
Matthew Hodgson
2018-04-29 04:28:15 +01:00
parent 731f1fa7d3
commit 551d3ebda0

View File

@@ -50,6 +50,7 @@ export default class extends React.Component {
this.onAction = this.onAction.bind(this); this.onAction = this.onAction.bind(this);
this.onImageError = this.onImageError.bind(this); this.onImageError = this.onImageError.bind(this);
this.onImageLoad = this.onImageLoad.bind(this);
this.onImageEnter = this.onImageEnter.bind(this); this.onImageEnter = this.onImageEnter.bind(this);
this.onImageLeave = this.onImageLeave.bind(this); this.onImageLeave = this.onImageLeave.bind(this);
this.onClientSync = this.onClientSync.bind(this); this.onClientSync = this.onClientSync.bind(this);
@@ -137,6 +138,11 @@ export default class extends React.Component {
}); });
} }
onImageLoad() {
this.fixupHeight();
this.props.onWidgetLoad();
}
_getContentUrl() { _getContentUrl() {
const content = this.props.mxEvent.getContent(); const content = this.props.mxEvent.getContent();
if (content.file !== undefined) { if (content.file !== undefined) {
@@ -170,7 +176,6 @@ export default class extends React.Component {
componentDidMount() { componentDidMount() {
this.dispatcherRef = dis.register(this.onAction); this.dispatcherRef = dis.register(this.onAction);
this.fixupHeight();
const content = this.props.mxEvent.getContent(); const content = this.props.mxEvent.getContent();
if (content.file !== undefined && this.state.decryptedUrl === null) { if (content.file !== undefined && this.state.decryptedUrl === null) {
let thumbnailPromise = Promise.resolve(null); let thumbnailPromise = Promise.resolve(null);
@@ -192,7 +197,6 @@ export default class extends React.Component {
decryptedThumbnailUrl: thumbnailUrl, decryptedThumbnailUrl: thumbnailUrl,
decryptedBlob: decryptedBlob, decryptedBlob: decryptedBlob,
}); });
this.props.onWidgetLoad();
}); });
}).catch((err) => { }).catch((err) => {
console.warn("Unable to decrypt attachment: ", err); console.warn("Unable to decrypt attachment: ", err);
@@ -259,7 +263,7 @@ export default class extends React.Component {
<img className="mx_MImageBody_thumbnail" src={thumbUrl} ref="image" <img className="mx_MImageBody_thumbnail" src={thumbUrl} ref="image"
alt={content.body} alt={content.body}
onError={this.onImageError} onError={this.onImageError}
onLoad={this.props.onWidgetLoad} onLoad={this.onImageLoad}
onMouseEnter={this.onImageEnter} onMouseEnter={this.onImageEnter}
onMouseLeave={this.onImageLeave} /> onMouseLeave={this.onImageLeave} />
</a> </a>