Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/mail.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2020-08-25 18:11:17 +0300
committerChristoph Wurst <christoph@winzerhof-wurst.at>2020-08-25 18:11:17 +0300
commitdd8330ae11a27cb620733b88f7e200f2483a401e (patch)
treec35864e81a5cf1af1d6d70a4269b3e7d442c6de0 /lib/Search
parentbd76d9d333f4c8ebddcdc298918e8e20c3a76053 (diff)
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: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib/Search')
-rw-r--r--lib/Search/Provider.php16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/Search/Provider.php b/lib/Search/Provider.php
index 3506f4665..4ece01356 100644
--- a/lib/Search/Provider.php
+++ b/lib/Search/Provider.php
@@ -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()
);
}
}