Bläddra i källkod

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).
arkon 2 år sedan
förälder
incheckning
7773deabc0
1 ändrade filer med 10 tillägg och 9 borttagningar
  1. 10 9
      app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt

+ 10 - 9
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)
+                }
             }
         }