From 89dd7beafed0536e1cf71381a94c601ba6ad597f Mon Sep 17 00:00:00 2001 From: Koitharu Date: Mon, 8 Apr 2024 10:08:15 +0300 Subject: [PATCH] Updated sort order for history and favorites --- .../org/koitharu/kotatsu/favourites/data/FavouritesDao.kt | 1 + .../kotlin/org/koitharu/kotatsu/history/data/HistoryDao.kt | 1 + .../org/koitharu/kotatsu/history/ui/HistoryListViewModel.kt | 1 + .../kotlin/org/koitharu/kotatsu/list/domain/ListSortOrder.kt | 3 +++ 4 files changed, 6 insertions(+) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/favourites/data/FavouritesDao.kt b/app/src/main/kotlin/org/koitharu/kotatsu/favourites/data/FavouritesDao.kt index 5b3d12e70..be0e55db0 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/favourites/data/FavouritesDao.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/favourites/data/FavouritesDao.kt @@ -210,6 +210,7 @@ abstract class FavouritesDao { ListSortOrder.UNREAD -> "IFNULL((SELECT percent FROM history WHERE history.manga_id = manga.manga_id), 0) ASC" ListSortOrder.LAST_READ -> "IFNULL((SELECT updated_at FROM history WHERE history.manga_id = manga.manga_id), 0) DESC" ListSortOrder.LONG_AGO_READ -> "IFNULL((SELECT updated_at FROM history WHERE history.manga_id = manga.manga_id), 0) ASC" + ListSortOrder.UPDATED -> "IFNULL((SELECT last_chapter_date FROM tracks WHERE tracks.manga_id = manga.manga_id), 0) DESC" else -> throw IllegalArgumentException("Sort order $sortOrder is not supported") } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/history/data/HistoryDao.kt b/app/src/main/kotlin/org/koitharu/kotatsu/history/data/HistoryDao.kt index e6575bbb9..236f79330 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/history/data/HistoryDao.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/history/data/HistoryDao.kt @@ -44,6 +44,7 @@ abstract class HistoryDao { ListSortOrder.ALPHABETIC -> "manga.title" ListSortOrder.ALPHABETIC_REVERSE -> "manga.title DESC" ListSortOrder.NEW_CHAPTERS -> "IFNULL((SELECT chapters_new FROM tracks WHERE tracks.manga_id = manga.manga_id), 0) DESC" + ListSortOrder.UPDATED -> "IFNULL((SELECT last_chapter_date FROM tracks WHERE tracks.manga_id = manga.manga_id), 0) DESC" else -> throw IllegalArgumentException("Sort order $order is not supported") } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/history/ui/HistoryListViewModel.kt b/app/src/main/kotlin/org/koitharu/kotatsu/history/ui/HistoryListViewModel.kt index 4b4dad579..973d4a42b 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/history/ui/HistoryListViewModel.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/history/ui/HistoryListViewModel.kt @@ -198,6 +198,7 @@ class HistoryListViewModel @Inject constructor( ListSortOrder.ALPHABETIC_REVERSE, ListSortOrder.RELEVANCE, ListSortOrder.NEW_CHAPTERS, + ListSortOrder.UPDATED, ListSortOrder.RATING -> null } } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/list/domain/ListSortOrder.kt b/app/src/main/kotlin/org/koitharu/kotatsu/list/domain/ListSortOrder.kt index 961d612b1..7bef961a2 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/list/domain/ListSortOrder.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/list/domain/ListSortOrder.kt @@ -20,6 +20,7 @@ enum class ListSortOrder( NEW_CHAPTERS(R.string.new_chapters), LAST_READ(R.string.last_read), LONG_AGO_READ(R.string.long_ago_read), + UPDATED(R.string.updated), ; fun isGroupingSupported() = this == LAST_READ || this == NEWEST || this == PROGRESS @@ -36,6 +37,7 @@ enum class ListSortOrder( ALPHABETIC, ALPHABETIC_REVERSE, NEW_CHAPTERS, + UPDATED, ) val FAVORITES: Set = EnumSet.of( ALPHABETIC, @@ -48,6 +50,7 @@ enum class ListSortOrder( UNREAD, LAST_READ, LONG_AGO_READ, + UPDATED, ) val SUGGESTIONS: Set = EnumSet.of(RELEVANCE)