mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2025-01-11 04:59:08 +01:00
Using maxOfOrNull in more places
This commit is contained in:
parent
3cf8b52025
commit
cf18b148cc
@ -111,7 +111,7 @@ class MigrationProcessAdapter(
|
||||
if (MigrationFlags.hasChapters(flags)) {
|
||||
val prevMangaChapters = db.getChapters(prevManga).executeAsBlocking()
|
||||
val maxChapterRead =
|
||||
prevMangaChapters.filter { it.read }.maxOf { it.chapter_number }
|
||||
prevMangaChapters.filter { it.read }.maxOfOrNull { it.chapter_number } ?: 0f
|
||||
val dbChapters = db.getChapters(manga).executeAsBlocking()
|
||||
val prevHistoryList = db.getHistoryByMangaId(prevManga.id!!).executeAsBlocking()
|
||||
val historyList = mutableListOf<History>()
|
||||
|
@ -96,7 +96,7 @@ fun syncChaptersWithSource(
|
||||
|
||||
// Return if there's nothing to add, delete or change, avoid unnecessary db transactions.
|
||||
if (toAdd.isEmpty() && toDelete.isEmpty() && toChange.isEmpty()) {
|
||||
val newestDate = dbChapters.maxOf { it.date_upload }
|
||||
val newestDate = dbChapters.maxOfOrNull { it.date_upload } ?: 0L
|
||||
if (newestDate != 0L && newestDate != manga.last_update) {
|
||||
manga.last_update = newestDate
|
||||
db.updateLastUpdated(manga).executeAsBlocking()
|
||||
@ -149,7 +149,7 @@ fun syncChaptersWithSource(
|
||||
db.fixChaptersSourceOrder(sourceChapters).executeAsBlocking()
|
||||
|
||||
// Set this manga as updated since chapters were changed
|
||||
val newestChapterDate = db.getChapters(manga).executeAsBlocking().maxOf { it.date_upload }
|
||||
val newestChapterDate = db.getChapters(manga).executeAsBlocking().maxOfOrNull { it.date_upload } ?: 0L
|
||||
if (newestChapterDate == 0L) {
|
||||
if (toAdd.isNotEmpty()) {
|
||||
manga.last_update = Date().time
|
||||
|
Loading…
x
Reference in New Issue
Block a user