Fix next expected update being weird number sometimes

Occurs if manga.lastUpdate has never been set yet.

(cherry picked from commit 22589a9c3056312dcbd0dfca08b53987cbc4a73d)

# Conflicts:
#	app/src/main/java/eu/kanade/domain/chapter/interactor/SyncChaptersWithSource.kt
This commit is contained in:
arkon
2024-01-01 18:32:21 -05:00
committed by Jobobby04
parent 98f4b7086a
commit 6398f92518
3 changed files with 24 additions and 35 deletions
@@ -19,16 +19,15 @@ class FetchInterval(
dateTime: ZonedDateTime,
window: Pair<Long, Long>,
): MangaUpdate? {
val interval = manga.fetchInterval.takeIf { it < 0 } ?: calculateInterval(
chapters = getChaptersByMangaId.await(manga.id, applyScanlatorFilter = true),
zone = dateTime.zone,
)
val currentWindow = if (window.first == 0L && window.second == 0L) {
getWindow(ZonedDateTime.now())
} else {
window
}
val chapters = getChaptersByMangaId.await(manga.id, applyScanlatorFilter = true)
val interval = manga.fetchInterval.takeIf { it < 0 } ?: calculateInterval(
chapters,
dateTime.zone,
)
val nextUpdate = calculateNextUpdate(manga, interval, dateTime, currentWindow)
return if (manga.nextUpdate == nextUpdate && manga.fetchInterval == interval) {
@@ -102,7 +101,7 @@ class FetchInterval(
manga.fetchInterval == 0
) {
val latestDate = ZonedDateTime.ofInstant(
Instant.ofEpochMilli(manga.lastUpdate),
if (manga.lastUpdate > 0) Instant.ofEpochMilli(manga.lastUpdate) else Instant.now(),
dateTime.zone,
)
.toLocalDate()