Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bundlesize.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
"files": [
{
"path": "packages/algoliasearch-helper/dist/algoliasearch.helper.js",
"maxSize": "43 kB"
"maxSize": "43.25 kB"
},
{
"path": "packages/algoliasearch-helper/dist/algoliasearch.helper.min.js",
"maxSize": "13.75 kB"
},
{
"path": "./packages/instantsearch.js/dist/instantsearch.production.min.js",
"maxSize": "121.25 kB"
"maxSize": "121.5 kB"
},
{
"path": "./packages/instantsearch.js/dist/instantsearch.development.js",
Expand Down
12 changes: 12 additions & 0 deletions packages/algoliasearch-helper/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1521,6 +1521,18 @@ declare namespace algoliasearchHelper {
* @return all the refinements
*/
getRefinements(): SearchResults.Refinement[];

/** Ordered array of per-feed results, present when results come from a multifeed composition response. */
feeds?: CompositionSearchResults[];
}

/**
* SearchResults from a composition feed response.
* Each feed in the composition response produces one of these.
*/
export interface CompositionSearchResults extends SearchResults {
/** The feed identifier for this result set. */
feedID: string;
}

export type Banner = {
Expand Down
33 changes: 25 additions & 8 deletions packages/algoliasearch-helper/src/algoliasearch.helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -1695,7 +1695,6 @@ AlgoliaSearchHelper.prototype._runComposition = function () {

states.push({
state: derivedState,
queriesCount: derivedStateQueries.length,
helper: derivedHelper,
});

Expand Down Expand Up @@ -1874,7 +1873,9 @@ AlgoliaSearchHelper.prototype._dispatchAlgoliaResponse = function (
var state = s.state;
var queriesCount = s.queriesCount;
var helper = s.helper;
var specificResults = results.splice(0, queriesCount);
var specificResults = queriesCount !== undefined
? results.splice(0, queriesCount)
: results;

if (!state.index) {
helper.emit('result', {
Expand All @@ -1884,12 +1885,28 @@ AlgoliaSearchHelper.prototype._dispatchAlgoliaResponse = function (
return;
}

helper.lastResults = new SearchResults(
state,
specificResults,
self._searchResultsOptions
);
if (rawContent !== undefined) helper.lastResults._rawContent = rawContent;
// Multifeed composition: build ordered SearchResults array on lastResults
if (specificResults.length > 0 && specificResults[0].feedID) {
var feeds = specificResults.map(function (r) {
var sr = new SearchResults(state, [r], self._searchResultsOptions);
if (rawContent !== undefined) sr._rawContent = rawContent;
return sr;
});
helper.lastResults = new SearchResults(
state,
[specificResults[0]],
self._searchResultsOptions
);
helper.lastResults.feeds = feeds;
if (rawContent !== undefined) helper.lastResults._rawContent = rawContent;
} else {
helper.lastResults = new SearchResults(
state,
specificResults,
self._searchResultsOptions
);
if (rawContent !== undefined) helper.lastResults._rawContent = rawContent;
}

helper.emit('result', {
results: helper.lastResults,
Expand Down
Loading
Loading