Skip to content

Commit da52419

Browse files
Satyarueckstiess
authored andcommitted
COMPASS-324: Document View not updating after query build via Schema (#602)
* COMPASS-324 added a count comparison of states in document-list shouldUpdateComponent * COMPASS-324 included equality comparison between returned docs
1 parent d0f5642 commit da52419

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/internal-packages/crud/lib/component/document-list.jsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const InsertDocumentStore = require('../store/insert-document-store');
1313
const InsertDocumentDialog = require('./insert-document-dialog');
1414
const Actions = require('../actions');
1515

16-
// const debug = require('debug')('mongodb-compass:crud');
16+
// const debug = require('debug')('mongodb-compass:crud:component');
1717

1818
/* eslint no-return-assign:0 */
1919

@@ -66,10 +66,17 @@ class DocumentList extends React.Component {
6666
* @returns {Boolean} If the component should update.
6767
*/
6868
shouldComponentUpdate(nextProps, nextState) {
69-
return (nextState.docs.length !== this.state.docs.length) ||
70-
(nextState.nextSkip !== this.state.nextSkip) ||
71-
(nextState.loadedCount !== this.state.loadedCount) ||
72-
(nextState.namespace !== this.state.namespace);
69+
// compare the states if they're different update component
70+
if ((nextState.docs.length !== this.state.docs.length)
71+
|| (nextState.nextSkip !== this.state.nextSkip)
72+
|| (nextState.loadedCount !== this.state.loadedCount)
73+
|| (nextState.namespace !== this.state.namespace)
74+
|| (nextState.count !== this.state.count)) {
75+
return true;
76+
}
77+
78+
// at this point compare the documents themselves and update if not different
79+
return !_.isEqual(nextState.docs, this.state.docs);
7380
}
7481

7582
/**

src/internal-packages/crud/lib/store/reset-document-list-store.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ const toNS = require('mongodb-ns');
66

77
// const debug = require('debug')('mongodb-compass:crud');
88

9+
// const debug = require('debug')('mongodb-compass:crud:store');
10+
911
/**
1012
* The default read preference.
1113
*/

0 commit comments

Comments
 (0)