Skip to content
Snippets Groups Projects
Unverified Commit dd8330ae authored by Christoph Wurst's avatar Christoph Wurst
Browse files

Fix the pagination in the unified search


Before it always returned $limit results but nothing more. Now it will
give back the actual page and a cursor, so the rest can be fetched in
consecutive search requests.

Signed-off-by: default avatarChristoph Wurst <christoph@winzerhof-wurst.at>
parent bd76d9d3
No related branches found
No related tags found
No related merge requests found
......@@ -75,14 +75,23 @@ class Provider implements IProvider {
}
public function search(IUser $user, ISearchQuery $query): SearchResult {
$cursor = $query->getCursor();
$messages = $this->mailSearch->findMessagesGlobally(
$user,
$query->getTerm(),
$query->getCursor(),
empty($cursor) ? null : ((int) $cursor),
$query->getLimit()
);
return SearchResult::complete(
$last = end($messages);
if ($last === false) {
return SearchResult::complete(
$this->getName(),
[]
);
}
return SearchResult::paginated(
$this->getName(),
array_map(function (Message $message) {
$formattedDate = $this->dateTimeFormatter->formatDateTimeRelativeDay($message->getSentAt(), 'short');
......@@ -103,7 +112,8 @@ class Provider implements IProvider {
]), // TODO: deep URL
'icon-mail'
);
}, $messages)
}, $messages),
$last->getSentAt()
);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment