Commit 70163a8
fix(InstantSearch): remove useless walk/duplicate request (#4127)
**Summary**
This PR removes a useless walk on the indices to apply the `SearchParameters`, it also removes a useless duplicate request (since we walk two times, we call search two times). At the `init` step we walk on the tree of indices to create each instance with their `uiState` and `SearchParameters`. It means that the state is already set, we don't have to trigger another walk.
The extra walk was called with the result of `read` which is not correct. Inside the constructor we already merge both `initialUiState` & `read`. If an `initialUiState` is present with refinements they are all overridden by `read`. With Storybook we mock the router to always return an empty object. It means that we always remove the `initialUiState` (see below).
You can also see the difference for the duplicate request on the e-commerce example. Here is the [link](https://5d81f53123e91200085f41ae--instantsearchjs.netlify.com/examples/e-commerce/) for the version prior to this PR. Open the DevTools you'll notice two identical requests on start. Here is the [link](https://deploy-preview-4127--instantsearchjs.netlify.com/examples/e-commerce/) for the version with this PR. Open the DevTools you'll notice only one request on start.
**Before**

You can check the live version on [Storybook](https://5d81f53123e91200085f41ae--instantsearchjs.netlify.com/stories/?path=/story/currentrefinements--with-refinementlist).
**After**

You can check the live version on [Storybook](https://deploy-preview-4127--instantsearchjs.netlify.com/stories/?path=/story/currentrefinements--with-refinementlist).1 parent 569d573 commit 70163a8
File tree
4 files changed
+38
-27
lines changed- src/lib
- __tests__
4 files changed
+38
-27
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
413 | 413 | | |
414 | 414 | | |
415 | 415 | | |
416 | | - | |
417 | 416 | | |
418 | 417 | | |
419 | 418 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | 37 | | |
62 | 38 | | |
63 | 39 | | |
| |||
76 | 52 | | |
77 | 53 | | |
78 | 54 | | |
79 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
80 | 75 | | |
81 | 76 | | |
82 | 77 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
488 | 488 | | |
489 | 489 | | |
490 | 490 | | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
491 | 508 | | |
492 | 509 | | |
493 | 510 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
142 | | - | |
| 142 | + | |
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| |||
0 commit comments