From 1d583229eeb4eb279c545b433e6160612df7a0b7 Mon Sep 17 00:00:00 2001 From: Gauthier Roebroeck Date: Mon, 13 Apr 2020 20:15:13 +0800 Subject: [PATCH] fix(api): libraries are not sorted for restricted users Closes: #140 --- .../org/gotson/komga/interfaces/rest/LibraryController.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/LibraryController.kt b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/LibraryController.kt index 830f366ea..e689232b0 100644 --- a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/LibraryController.kt +++ b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/LibraryController.kt @@ -10,7 +10,6 @@ import org.gotson.komga.domain.model.PathContainedInPath import org.gotson.komga.domain.persistence.BookRepository import org.gotson.komga.domain.persistence.LibraryRepository import org.gotson.komga.infrastructure.security.KomgaPrincipal -import org.springframework.data.domain.Sort import org.springframework.data.repository.findByIdOrNull import org.springframework.http.HttpStatus import org.springframework.http.MediaType @@ -46,10 +45,10 @@ class LibraryController( @AuthenticationPrincipal principal: KomgaPrincipal ): List = if (principal.user.sharedAllLibraries) { - libraryRepository.findAll(Sort.by("name")) + libraryRepository.findAll() } else { principal.user.sharedLibraries - }.map { it.toDto(includeRoot = principal.user.isAdmin()) } + }.sortedBy { it.name }.map { it.toDto(includeRoot = principal.user.isAdmin()) } @GetMapping("{id}") fun getOne(