From 247a39c0a9a8881b5aec275740a007675938601f Mon Sep 17 00:00:00 2001 From: FlaminSarge Date: Sun, 16 Feb 2020 07:17:43 -0700 Subject: [PATCH] Move empty-chapterlist manga to end of Latest Chapter sort in Library view --- .../eu/kanade/tachiyomi/data/database/queries/RawQueries.kt | 4 ++-- .../java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/queries/RawQueries.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/queries/RawQueries.kt index f3c7389dfb..554c238b58 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/queries/RawQueries.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/queries/RawQueries.kt @@ -93,7 +93,7 @@ fun getLastReadMangaQuery() = """ ORDER BY max DESC """ -fun getTotalChapterMangaQuery()= """ +fun getTotalChapterMangaQuery() = """ SELECT ${Manga.TABLE}.* FROM ${Manga.TABLE} JOIN ${Chapter.TABLE} @@ -102,7 +102,7 @@ fun getTotalChapterMangaQuery()= """ ORDER by COUNT(*) """ -fun getLatestChapterMangaQuery()= """ +fun getLatestChapterMangaQuery() = """ SELECT ${Manga.TABLE}.*, MAX(${Chapter.TABLE}.${Chapter.COL_DATE_UPLOAD}) AS max FROM ${Manga.TABLE} JOIN ${Chapter.TABLE} diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt index eb7a5802fc..1886b93efc 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt @@ -207,8 +207,10 @@ class LibraryPresenter( manga1TotalChapter.compareTo(mange2TotalChapter) } LibrarySort.LATEST_CHAPTER -> { - val manga1latestChapter = latestChapterManga[i1.manga.id!!] ?: 0 - val manga2latestChapter = latestChapterManga[i2.manga.id!!] ?: 0 + val manga1latestChapter = latestChapterManga[i1.manga.id!!] + ?: latestChapterManga.size + val manga2latestChapter = latestChapterManga[i2.manga.id!!] + ?: latestChapterManga.size manga1latestChapter.compareTo(manga2latestChapter) } else -> throw Exception("Unknown sorting mode")