-
Notifications
You must be signed in to change notification settings - Fork 554
feat(helper): support multifeed composition responses #6954
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
base: feat/composition-multifeed
Are you sure you want to change the base?
Changes from 4 commits
a49091b
343e93a
450d71a
4ce052c
46ee2b1
3b56311
ec3854e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1695,7 +1695,6 @@ AlgoliaSearchHelper.prototype._runComposition = function () { | |
|
|
||
| states.push({ | ||
| state: derivedState, | ||
| queriesCount: derivedStateQueries.length, | ||
| helper: derivedHelper, | ||
| }); | ||
|
|
||
|
|
@@ -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', { | ||
|
|
@@ -1884,12 +1885,33 @@ AlgoliaSearchHelper.prototype._dispatchAlgoliaResponse = function ( | |
| return; | ||
| } | ||
|
|
||
| helper.lastResults = new SearchResults( | ||
| state, | ||
| specificResults, | ||
| self._searchResultsOptions | ||
| ); | ||
| if (rawContent !== undefined) helper.lastResults._rawContent = rawContent; | ||
| // Multifeed composition: build per-feed SearchResults map | ||
| if (specificResults.length > 0 && specificResults[0].feedID) { | ||
| var feedResults = {}; | ||
| var feedOrder = specificResults.map(function (r) { | ||
| return r.feedID; | ||
| }); | ||
| specificResults.forEach(function (r) { | ||
| var sr = new SearchResults(state, [r], self._searchResultsOptions); | ||
| if (rawContent !== undefined) sr._rawContent = rawContent; | ||
| feedResults[r.feedID] = sr; | ||
| }); | ||
| helper.lastResults = new SearchResults( | ||
| state, | ||
| [specificResults[0]], | ||
| self._searchResultsOptions | ||
| ); | ||
| if (rawContent !== undefined) helper.lastResults._rawContent = rawContent; | ||
| helper.lastResults._feedResults = feedResults; | ||
| helper.lastResults._feedOrder = feedOrder; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not overly sold on putting this behind _ keys that we then need to explicitly handle in the implementation. It's ok bu have you considered also why is there the results and the order needed separately? could it be just a single array that in case you have a feature of displaying just a single feed it just does find in the array.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as discussed I went with
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since its now one property only I added back feeds on to |
||
| } else { | ||
| helper.lastResults = new SearchResults( | ||
| state, | ||
| specificResults, | ||
| self._searchResultsOptions | ||
| ); | ||
| if (rawContent !== undefined) helper.lastResults._rawContent = rawContent; | ||
| } | ||
|
|
||
| helper.emit('result', { | ||
| results: helper.lastResults, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.