Skip to content

Commit bf46684

Browse files
authored
COMPASS-291 only call setState once in apply/reset (#616)
1 parent c1ea8fe commit bf46684

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/internal-packages/query/lib/store/query-store.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,14 +409,13 @@ const QueryStore = Reflux.createStore({
409409
return;
410410
}
411411

412-
this.setState({queryState: APPLY_STATE});
413-
414412
// empty string is interpreted as {}
415413
if (this.state.queryString === '') {
416414
this.setQuery({});
417415
}
418416
if (this.state.valid) {
419417
this.setState({
418+
queryState: APPLY_STATE,
420419
lastExecutedQuery: _.clone(this.state.query)
421420
});
422421
}
@@ -426,12 +425,12 @@ const QueryStore = Reflux.createStore({
426425
* dismiss current changes to the query and restore `{}` as the query.
427426
*/
428427
reset() {
429-
this.setState({queryState: RESET_STATE});
430428
if (!_.isEqual(this.state.query, {})) {
431429
this.setQuery({});
432430
if (!_.isEqual(this.state.lastExecutedQuery, {})) {
433431
if (this.state.valid) {
434432
this.setState({
433+
queryState: RESET_STATE,
435434
lastExecutedQuery: _.clone(this.state.query)
436435
});
437436
}

0 commit comments

Comments
 (0)