mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-10 01:35:09 +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)) {
|
if (MigrationFlags.hasChapters(flags)) {
|
||||||
val prevMangaChapters = db.getChapters(prevManga).executeAsBlocking()
|
val prevMangaChapters = db.getChapters(prevManga).executeAsBlocking()
|
||||||
val maxChapterRead =
|
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 dbChapters = db.getChapters(manga).executeAsBlocking()
|
||||||
val prevHistoryList = db.getHistoryByMangaId(prevManga.id!!).executeAsBlocking()
|
val prevHistoryList = db.getHistoryByMangaId(prevManga.id!!).executeAsBlocking()
|
||||||
val historyList = mutableListOf<History>()
|
val historyList = mutableListOf<History>()
|
||||||
|
@ -96,7 +96,7 @@ fun syncChaptersWithSource(
|
|||||||
|
|
||||||
// Return if there's nothing to add, delete or change, avoid unnecessary db transactions.
|
// Return if there's nothing to add, delete or change, avoid unnecessary db transactions.
|
||||||
if (toAdd.isEmpty() && toDelete.isEmpty() && toChange.isEmpty()) {
|
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) {
|
if (newestDate != 0L && newestDate != manga.last_update) {
|
||||||
manga.last_update = newestDate
|
manga.last_update = newestDate
|
||||||
db.updateLastUpdated(manga).executeAsBlocking()
|
db.updateLastUpdated(manga).executeAsBlocking()
|
||||||
@ -149,7 +149,7 @@ fun syncChaptersWithSource(
|
|||||||
db.fixChaptersSourceOrder(sourceChapters).executeAsBlocking()
|
db.fixChaptersSourceOrder(sourceChapters).executeAsBlocking()
|
||||||
|
|
||||||
// Set this manga as updated since chapters were changed
|
// 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 (newestChapterDate == 0L) {
|
||||||
if (toAdd.isNotEmpty()) {
|
if (toAdd.isNotEmpty()) {
|
||||||
manga.last_update = Date().time
|
manga.last_update = Date().time
|
||||||
|
Loading…
Reference in New Issue
Block a user