diff --git a/src/components/views/messages/MImageBody.js b/src/components/views/messages/MImageBody.js index ceede48554..6a95b3c16e 100644 --- a/src/components/views/messages/MImageBody.js +++ b/src/components/views/messages/MImageBody.js @@ -204,6 +204,12 @@ export default class extends React.Component { this.unmounted = true; dis.unregister(this.dispatcherRef); this.context.matrixClient.removeListener('sync', this.onClientSync); + this._afterComponentWillUnmount(); + } + + // To be overridden by subclasses (e.g. MStickerBody) for further + // cleanup after componentWillUnmount + _afterComponentWillUnmount() { } onAction(payload) { diff --git a/src/components/views/messages/MStickerBody.js b/src/components/views/messages/MStickerBody.js index 8b5e0d1043..e1039ae66b 100644 --- a/src/components/views/messages/MStickerBody.js +++ b/src/components/views/messages/MStickerBody.js @@ -43,12 +43,13 @@ export default class MStickerBody extends MImageBody { this.setState({ placeholderClasses: 'mx_MStickerBody_placeholder_invisible', }); - setTimeout(() => { + const hidePlaceholderTimer = setTimeout(() => { this.setState({ placeholderVisible: false, thumbnailClasses: 'mx_MStickerBody_thumbnail_visible', }); }, 500); + this.setState({hidePlaceholderTimer}); } _afterComponentDidMount() { @@ -69,6 +70,13 @@ export default class MStickerBody extends MImageBody { } } + _afterComponentWillUnmount() { + if (this.state.hidePlaceholderTimer) { + clearTimeout(this.state.hidePlaceholderTimer); + this.setState({hidePlaceholderTimer: null}); + } + } + _messageContent(contentUrl, thumbUrl, content) { let tooltip; const tooltipBody = (