From 5c2704ed9c07e6dd4446634a99dc48b2d0ba127e Mon Sep 17 00:00:00 2001 From: KeyboardTsundoku Date: Thu, 17 Nov 2016 14:51:09 +1100 Subject: [PATCH 1/2] COMPASS-324 added a count comparison of states in document-list shouldUpdateComponent --- src/internal-packages/crud/lib/component/document-list.jsx | 5 +++-- .../crud/lib/store/reset-document-list-store.js | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/internal-packages/crud/lib/component/document-list.jsx b/src/internal-packages/crud/lib/component/document-list.jsx index 66d4047a494..69879ff89a6 100644 --- a/src/internal-packages/crud/lib/component/document-list.jsx +++ b/src/internal-packages/crud/lib/component/document-list.jsx @@ -13,7 +13,7 @@ const InsertDocumentStore = require('../store/insert-document-store'); const InsertDocumentDialog = require('./insert-document-dialog'); const Actions = require('../actions'); -// const debug = require('debug')('mongodb-compass:crud'); +// const debug = require('debug')('mongodb-compass:crud:component'); /* eslint no-return-assign:0 */ @@ -69,7 +69,8 @@ class DocumentList extends React.Component { return (nextState.docs.length !== this.state.docs.length) || (nextState.nextSkip !== this.state.nextSkip) || (nextState.loadedCount !== this.state.loadedCount) || - (nextState.namespace !== this.state.namespace); + (nextState.namespace !== this.state.namespace) || + (nextState.count !== this.state.count); } /** diff --git a/src/internal-packages/crud/lib/store/reset-document-list-store.js b/src/internal-packages/crud/lib/store/reset-document-list-store.js index cdfb49a1c18..0503defc43a 100644 --- a/src/internal-packages/crud/lib/store/reset-document-list-store.js +++ b/src/internal-packages/crud/lib/store/reset-document-list-store.js @@ -6,6 +6,8 @@ const toNS = require('mongodb-ns'); // const debug = require('debug')('mongodb-compass:crud'); +// const debug = require('debug')('mongodb-compass:crud:store'); + /** * The default read preference. */ From a04a3d52cdf90e40ef70477748be25869e4ded8e Mon Sep 17 00:00:00 2001 From: KeyboardTsundoku Date: Sat, 19 Nov 2016 16:28:23 +1100 Subject: [PATCH 2/2] COMPASS-324 included equality comparison between returned docs --- .../crud/lib/component/document-list.jsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/internal-packages/crud/lib/component/document-list.jsx b/src/internal-packages/crud/lib/component/document-list.jsx index 69879ff89a6..adec82cc1db 100644 --- a/src/internal-packages/crud/lib/component/document-list.jsx +++ b/src/internal-packages/crud/lib/component/document-list.jsx @@ -66,11 +66,17 @@ class DocumentList extends React.Component { * @returns {Boolean} If the component should update. */ shouldComponentUpdate(nextProps, nextState) { - return (nextState.docs.length !== this.state.docs.length) || - (nextState.nextSkip !== this.state.nextSkip) || - (nextState.loadedCount !== this.state.loadedCount) || - (nextState.namespace !== this.state.namespace) || - (nextState.count !== this.state.count); + // compare the states if they're different update component + if ((nextState.docs.length !== this.state.docs.length) + || (nextState.nextSkip !== this.state.nextSkip) + || (nextState.loadedCount !== this.state.loadedCount) + || (nextState.namespace !== this.state.namespace) + || (nextState.count !== this.state.count)) { + return true; + } + + // at this point compare the documents themselves and update if not different + return !_.isEqual(nextState.docs, this.state.docs); } /**