Fix crash in migration if there are no viable chapter numbers

This commit is contained in:
Jobobby04 2021-04-15 15:03:44 -04:00
parent 13f4bfa7bc
commit f4c6b2e09c

View File

@ -104,7 +104,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 }
val dbChapters = db.getChapters(manga).executeAsBlocking()
val prevHistoryList = db.getHistoryByMangaId(prevManga.id!!).executeAsBlocking()
val historyList = mutableListOf<History>()
@ -120,7 +120,7 @@ class MigrationProcessAdapter(
val history = History.create(chapter).apply { last_read = prevHistory.last_read }
historyList.add(history)
}
} else if (chapter.chapter_number <= maxChapterRead) {
} else if (maxChapterRead != null && chapter.chapter_number <= maxChapterRead) {
chapter.read = true
}
}