@@ -360,7 +360,7 @@ function combineEvents(previousSearchResult, localEvents = undefined, serverEven
360360 let oldestEventFrom = previousSearchResult . oldestEventFrom ;
361361 response . highlights = previousSearchResult . highlights ;
362362
363- if ( localEvents && serverEvents ) {
363+ if ( localEvents && serverEvents && serverEvents . results ) {
364364 // This is a first search call, combine the events from the server and
365365 // the local index. Note where our oldest event came from, we shall
366366 // fetch the next batch of events from the other source.
@@ -379,7 +379,7 @@ function combineEvents(previousSearchResult, localEvents = undefined, serverEven
379379 oldestEventFrom = "local" ;
380380 }
381381 combineEventSources ( previousSearchResult , response , localEvents . results , cachedEvents ) ;
382- } else if ( serverEvents ) {
382+ } else if ( serverEvents && serverEvents . results ) {
383383 // This is a pagination call fetching more events from the server,
384384 // meaning that our oldest event was in the local index.
385385 // Change the source of the oldest event if our server event is older
@@ -454,7 +454,7 @@ function combineResponses(previousSearchResult, localEvents = undefined, serverE
454454 return response ;
455455}
456456
457- function restoreEncryptionInfo ( searchResultSlice ) {
457+ function restoreEncryptionInfo ( searchResultSlice = [ ] ) {
458458 for ( let i = 0 ; i < searchResultSlice . length ; i ++ ) {
459459 const timeline = searchResultSlice [ i ] . context . getTimeline ( ) ;
460460
@@ -517,7 +517,7 @@ async function combinedPagination(searchResult) {
517517 } ,
518518 } ;
519519
520- const oldResultCount = searchResult . results . length ;
520+ const oldResultCount = searchResult . results ? searchResult . results . length : 0 ;
521521
522522 // Let the client process the combined result.
523523 const result = client . _processRoomEventsSearch ( searchResult , response ) ;
0 commit comments