mirror of
https://github.com/element-hq/element-web
synced 2024-11-27 19:56:47 +03:00
Searching: Split out more logic that combines the events.
This commit is contained in:
parent
b6198e0ab9
commit
c2e0e10553
1 changed files with 16 additions and 10 deletions
|
@ -184,18 +184,9 @@ async function localPagination(searchResult) {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Combine the local and server search results
|
||||
*/
|
||||
function combineResponses(previousSearchResult, localEvents = undefined, serverEvents = undefined) {
|
||||
function combineEvents(localEvents = undefined, serverEvents = undefined, cachedEvents = undefined) {
|
||||
const response = {};
|
||||
|
||||
if (previousSearchResult.count) {
|
||||
response.count = previousSearchResult.count;
|
||||
} else {
|
||||
response.count = localEvents.count + serverEvents.count;
|
||||
}
|
||||
|
||||
if (localEvents && serverEvents) {
|
||||
response.results = localEvents.results.concat(serverEvents.results).sort(compareEvents);
|
||||
response.highlights = localEvents.highlights.concat(serverEvents.highlights);
|
||||
|
@ -207,6 +198,21 @@ function combineResponses(previousSearchResult, localEvents = undefined, serverE
|
|||
response.highlights = serverEvents.highlights;
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Combine the local and server search responses
|
||||
*/
|
||||
function combineResponses(previousSearchResult, localEvents = undefined, serverEvents = undefined) {
|
||||
const response = combineEvents(localEvents, serverEvents);
|
||||
|
||||
if (previousSearchResult.count) {
|
||||
response.count = previousSearchResult.count;
|
||||
} else {
|
||||
response.count = localEvents.count + serverEvents.count;
|
||||
}
|
||||
|
||||
if (localEvents) {
|
||||
previousSearchResult.seshatQuery.next_batch = localEvents.next_batch;
|
||||
response.next_batch = localEvents.next_batch;
|
||||
|
|
Loading…
Reference in a new issue