Fix next_batch

This commit is contained in:
Till Faelligen 2022-09-15 14:44:20 +02:00
parent 6c969b6c9d
commit 91c82c5198
No known key found for this signature in database
GPG key ID: 3DF82D8AB9211D4E

View file

@ -218,9 +218,10 @@ func Search(req *http.Request, device *api.Device, syncDB storage.Database, fts
} }
} }
nb := "" var nextBatchResult *string = nil
if int(result.Total) > nextBatch+len(results) { if int(result.Total) > nextBatch+len(results) {
nb = strconv.Itoa(len(results) + nextBatch) nb := strconv.Itoa(len(results) + nextBatch)
nextBatchResult = &nb
} }
res := SearchResponse{ res := SearchResponse{
@ -229,7 +230,7 @@ func Search(req *http.Request, device *api.Device, syncDB storage.Database, fts
Count: int(result.Total), Count: int(result.Total),
Groups: Groups{RoomID: groups}, Groups: Groups{RoomID: groups},
Results: results, Results: results,
NextBatch: &nb, NextBatch: nextBatchResult,
Highlights: strings.Split(searchReq.SearchCategories.RoomEvents.SearchTerm, " "), Highlights: strings.Split(searchReq.SearchCategories.RoomEvents.SearchTerm, " "),
State: stateForRooms, State: stateForRooms,
}, },