diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/migration/manga/process/MigrationProcessAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/migration/manga/process/MigrationProcessAdapter.kt index ed3d9a8224..8fe5d2c24b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/migration/manga/process/MigrationProcessAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/migration/manga/process/MigrationProcessAdapter.kt @@ -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() diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterSourceSync.kt b/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterSourceSync.kt index b1567d8015..d4266c42e2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterSourceSync.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterSourceSync.kt @@ -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