Merge pull request #3294 from matrix-org/t3chguy/mount-guard

Add mount-guards to MImageBody
This commit is contained in:
Michael Telatynski 2019-08-09 16:55:08 +01:00 committed by GitHub
commit 13c7149592
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,7 +1,7 @@
/* /*
Copyright 2015, 2016 OpenMarket Ltd Copyright 2015, 2016 OpenMarket Ltd
Copyright 2018 New Vector Ltd Copyright 2018 New Vector Ltd
Copyright 2018 Michael Telatynski <7t3chguy@gmail.com> Copyright 2018, 2019 Michael Telatynski <7t3chguy@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -264,6 +264,7 @@ export default class MImageBody extends React.Component {
decryptedBlob = blob; decryptedBlob = blob;
return URL.createObjectURL(blob); return URL.createObjectURL(blob);
}).then((contentUrl) => { }).then((contentUrl) => {
if (this.unmounted) return;
this.setState({ this.setState({
decryptedUrl: contentUrl, decryptedUrl: contentUrl,
decryptedThumbnailUrl: thumbnailUrl, decryptedThumbnailUrl: thumbnailUrl,
@ -271,6 +272,7 @@ export default class MImageBody extends React.Component {
}); });
}); });
}).catch((err) => { }).catch((err) => {
if (this.unmounted) return;
console.warn("Unable to decrypt attachment: ", err); console.warn("Unable to decrypt attachment: ", err);
// Set a placeholder image when we can't decrypt the image. // Set a placeholder image when we can't decrypt the image.
this.setState({ this.setState({