From 7773deabc03eb106798aed113341acf66a5f6a77 Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 24 Apr 2022 15:50:51 -0400 Subject: [PATCH] Adjust library sorting by dates (closes #6954) Ascending by date = oldest dates first. If no date is present, fallback to epoch 0 (i.e., oldest). --- .../tachiyomi/ui/library/LibraryPresenter.kt | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) 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 44ee49e4d..f0a925e19 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 @@ -284,12 +284,13 @@ class LibraryPresenter( collator.compare(i1.manga.title.lowercase(locale), i2.manga.title.lowercase(locale)) } SortModeSetting.LAST_READ -> { - // Get index of manga, set equal to list if size unknown. - val manga1LastRead = lastReadManga[i1.manga.id!!] ?: lastReadManga.size - val manga2LastRead = lastReadManga[i2.manga.id!!] ?: lastReadManga.size + val manga1LastRead = lastReadManga[i1.manga.id!!] ?: 0 + val manga2LastRead = lastReadManga[i2.manga.id!!] ?: 0 manga1LastRead.compareTo(manga2LastRead) } - SortModeSetting.LAST_CHECKED -> i2.manga.last_update.compareTo(i1.manga.last_update) + SortModeSetting.LAST_CHECKED -> { + i1.manga.last_update.compareTo(i2.manga.last_update) + } SortModeSetting.UNREAD -> when { // Ensure unread content comes first i1.manga.unreadCount == i2.manga.unreadCount -> 0 @@ -308,13 +309,13 @@ class LibraryPresenter( manga1latestChapter.compareTo(manga2latestChapter) } SortModeSetting.DATE_FETCHED -> { - val manga1chapterFetchDate = chapterFetchDateManga[i1.manga.id!!] - ?: chapterFetchDateManga.size - val manga2chapterFetchDate = chapterFetchDateManga[i2.manga.id!!] - ?: chapterFetchDateManga.size + val manga1chapterFetchDate = chapterFetchDateManga[i1.manga.id!!] ?: 0 + val manga2chapterFetchDate = chapterFetchDateManga[i2.manga.id!!] ?: 0 manga1chapterFetchDate.compareTo(manga2chapterFetchDate) } - SortModeSetting.DATE_ADDED -> i2.manga.date_added.compareTo(i1.manga.date_added) + SortModeSetting.DATE_ADDED -> { + i1.manga.date_added.compareTo(i2.manga.date_added) + } } }