-
Notifications
You must be signed in to change notification settings - Fork 531
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(routing): ensure UiState is cleaned up allowing "undefined" for values #5956
Conversation
also somewhat more efficient as no loops are done
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit ab708dd:
|
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.
Looks correct to me.
As mentioned previously, removeEmptyRefinementsFromUiState
looks factorizable, we could have a single util instead of the same function everywhere. I'll let you be the judge of whether we should do it now or keep it for later.
The types make it too hard to make factorable, as well as the conditions not being exactly the same anymore. I tried it but will focus again after this is merged/released |
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.
🙇
Summary
Since #5912, we ensure to clean the UiState from empty values, however this was done in a slightly inefficient (looping over values) and unsafe (no checking for undefined) way, as the types implied that RouteState/UiState always is completely given (if you're using TypeScript that's actually the case, you'd get an error returning
undefined
for refinementList[attribute] for example).Result
undefined
doesn't cause issuesconnectors/*/routing
where relevant (pushed the tests separately to show they fail with current implementation: https://app.circleci.com/pipelines/github/algolia/instantsearch/9831/workflows/cba7210e-6955-4459-8c82-307d77319955/jobs/47848/tests)fixes #5954