mirror of
https://github.com/nextcloud/integration_moodle.git
synced 2025-12-17 21:02:05 +01:00
fix paginated search
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
This commit is contained in:
parent
c04a027ff1
commit
39d19aa518
1 changed files with 3 additions and 3 deletions
|
|
@ -103,14 +103,13 @@ class MoodleSearchProvider implements IProvider {
|
|||
$limit = $query->getLimit();
|
||||
$term = $query->getTerm();
|
||||
$offset = $query->getCursor();
|
||||
$offset = $offset ? intval($offset) : 0;
|
||||
|
||||
$theme = $this->config->getUserValue($user->getUID(), 'accessibility', 'theme', '');
|
||||
$thumbnailUrl = ($theme === 'dark') ?
|
||||
$this->urlGenerator->imagePath(Application::APP_ID, 'app.svg') :
|
||||
$this->urlGenerator->imagePath(Application::APP_ID, 'app-dark.svg');
|
||||
|
||||
$resultBills = [];
|
||||
|
||||
$moodleUrl = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'url', '');
|
||||
$accessToken = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'token', '');
|
||||
$searchEnabled = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'search_enabled', '0') === '1';
|
||||
|
|
@ -119,6 +118,7 @@ class MoodleSearchProvider implements IProvider {
|
|||
}
|
||||
|
||||
$searchResults = $this->service->search($moodleUrl, $accessToken, $term);
|
||||
$searchResults = array_slice($searchResults, $offset, $limit);
|
||||
|
||||
$formattedResults = \array_map(function (array $entry) use ($thumbnailUrl, $moodleUrl): MoodleSearchResultEntry {
|
||||
return new MoodleSearchResultEntry(
|
||||
|
|
@ -134,7 +134,7 @@ class MoodleSearchProvider implements IProvider {
|
|||
return SearchResult::paginated(
|
||||
$this->getName(),
|
||||
$formattedResults,
|
||||
$query->getCursor() + count($formattedResults)
|
||||
$offset + $limit
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue