From b9e69a1c9a194c9c0fd60ebfe2b8f954e6f9ca04 Mon Sep 17 00:00:00 2001 From: Gauthier Roebroeck Date: Thu, 28 Jul 2022 09:34:07 +0800 Subject: [PATCH] feat(api): allow readlist custom sorting --- .../kotlin/org/gotson/komga/infrastructure/jooq/ReadListDao.kt | 2 ++ .../org/gotson/komga/interfaces/api/rest/ReadListController.kt | 1 + 2 files changed, 3 insertions(+) diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ReadListDao.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ReadListDao.kt index fcae9ac60..00d32183e 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ReadListDao.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ReadListDao.kt @@ -37,6 +37,8 @@ class ReadListDao( private val sorts = mapOf( "name" to rl.NAME.collate(SqliteUdfDataSource.collationUnicode3), + "createdDate" to rl.CREATED_DATE, + "lastModifiedDate" to rl.LAST_MODIFIED_DATE, ) override fun findByIdOrNull(readListId: String, filterOnLibraryIds: Collection?, restrictions: ContentRestrictions): ReadList? = diff --git a/komga/src/main/kotlin/org/gotson/komga/interfaces/api/rest/ReadListController.kt b/komga/src/main/kotlin/org/gotson/komga/interfaces/api/rest/ReadListController.kt index 8fa343063..5ca0fe8a2 100644 --- a/komga/src/main/kotlin/org/gotson/komga/interfaces/api/rest/ReadListController.kt +++ b/komga/src/main/kotlin/org/gotson/komga/interfaces/api/rest/ReadListController.kt @@ -103,6 +103,7 @@ class ReadListController( @Parameter(hidden = true) page: Pageable, ): Page { val sort = when { + page.sort.isSorted -> page.sort !searchTerm.isNullOrBlank() -> Sort.by("relevance") else -> Sort.by(Sort.Order.asc("name")) }