Fix infinite loop retrieving post files (#4192)

* Fix infinite loop retrieving post files

Right now if all the attachments of a post are removed the component
update code enters into an infinite loop because the comparison between
arrays always return false.
This commit is contained in:
Mario de Frutos Dieguez 2020-04-22 19:25:34 +02:00 committed by GitHub
parent 9a97f91735
commit 3de2b29570
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -69,13 +69,11 @@ export default class FileAttachmentList extends PureComponent {
}
componentDidUpdate(prevProps) {
if (prevProps.files !== this.props.files) {
if (prevProps.files.length !== this.props.files.length) {
this.filesForGallery = this.getFilesForGallery(this.props);
this.buildGalleryFiles().then((results) => {
this.galleryFiles = results;
});
}
if (this.props.files !== prevProps.files && this.props.files.length === 0) {
this.loadFilesForPost();
}
}