From 3de2b295701ae6cf778b7ea9c99e0afe45f63fbf Mon Sep 17 00:00:00 2001 From: Mario de Frutos Dieguez Date: Wed, 22 Apr 2020 19:25:34 +0200 Subject: [PATCH] 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. --- app/components/file_attachment_list/file_attachment_list.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/components/file_attachment_list/file_attachment_list.js b/app/components/file_attachment_list/file_attachment_list.js index dcb70674c..de66e1385 100644 --- a/app/components/file_attachment_list/file_attachment_list.js +++ b/app/components/file_attachment_list/file_attachment_list.js @@ -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(); } }