Skip to content

Commit

Permalink
fix(queries): prevent network request (#6205)
Browse files Browse the repository at this point in the history
  • Loading branch information
Haroenv committed May 21, 2024
1 parent b6037c0 commit 0154995
Show file tree
Hide file tree
Showing 11 changed files with 591 additions and 21 deletions.
6 changes: 3 additions & 3 deletions bundlesize.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@
},
{
"path": "./packages/instantsearch.js/dist/instantsearch.production.min.js",
"maxSize": "80.5 kB"
"maxSize": "81.5 kB"
},
{
"path": "./packages/instantsearch.js/dist/instantsearch.development.js",
"maxSize": "190 kB"
},
{
"path": "packages/react-instantsearch-core/dist/umd/ReactInstantSearchCore.min.js",
"maxSize": "48.5 kB"
"maxSize": "49.5 kB"
},
{
"path": "packages/react-instantsearch/dist/umd/ReactInstantSearch.min.js",
"maxSize": "62 kB"
"maxSize": "62.5 kB"
},
{
"path": "packages/vue-instantsearch/vue2/umd/index.js",
Expand Down
14 changes: 11 additions & 3 deletions packages/instantsearch.js/src/lib/InstantSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ class InstantSearch<
public _createURL: CreateURL<TUiState>;
public _searchFunction?: InstantSearchOptions['searchFunction'];
public _mainHelperSearch?: AlgoliaSearchHelper['search'];
public _hasSearchWidget: boolean = false;
public _hasRecommendWidget: boolean = false;
public _insights: InstantSearchOptions['insights'];
public middleware: Array<{
creator: Middleware<TUiState>;
Expand Down Expand Up @@ -580,9 +582,15 @@ See documentation: ${createDocumentationLink({
// under the hood, we have a different implementation. It should be
// completely transparent for the rest of the codebase. Only this module
// is impacted.
return (
mainHelper.searchOnlyWithDerivedHelpers() && mainHelper.recommend()
);
if (this._hasSearchWidget) {
mainHelper.searchOnlyWithDerivedHelpers();
}

if (this._hasRecommendWidget) {
mainHelper.recommend();
}

return mainHelper;
};

if (this._searchFunction) {
Expand Down
Loading

0 comments on commit 0154995

Please sign in to comment.