New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(queries): Ignore duplicate recent queries COMPASS-2237 #3171
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does solve the duplicate entries pain point, however I think as a user I'd expect/like if the recent query I use goes to the top of the recents list when it's used.
Is it possible to update the _lastExecuted
entry for the matching recent when a query is performed?
@@ -25,7 +24,9 @@ const configureStore = (options = {}) => { | |||
* Filter attributes that aren't query fields or have default/empty values. | |||
* @param {object} attributes | |||
*/ | |||
_filterDefaults(attributes) { | |||
_filterDefaults(_attributes) { | |||
// don't mutate the passed in parameter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lost some time here. My test that added the same query twice actually never executed the code that would check if it is a duplicate because this stripped ns from the query the first time, causing it to early return for a different reason.
I think it is just better style to not implicitly modify things that came in from the outside.
return isDeepStrictEqual(_item.filter, query.filter); | ||
const existingQuery = this.state.items | ||
.find((item) => { | ||
return _.isEqual(comparableQuery(item), query); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found a second copy of this logic / a third place that could benefit from the new function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
This won't save a query that already exists in the recents again. It also moves a bunch of tests that were in test/renderer and therefore ignored to the right places so they run again.