You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-07 10:46:24 +03:00
Searching: Split out more logic that combines the events.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user