Restore chapter's bookmark & oldest dateUpload from backup (#659)

This commit is contained in:
Cuong-Tran 2025-01-26 01:58:32 +07:00 committed by GitHub
parent 4c7563294d
commit 4a0c1384d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -31,6 +31,7 @@ import uy.kohesive.injekt.api.get
import java.time.ZonedDateTime
import java.util.Date
import kotlin.math.max
import kotlin.math.min
class MangaRestorer(
private var isSync: Boolean = false,
@ -206,20 +207,28 @@ class MangaRestorer(
read = chapter.read,
lastPageRead = chapter.lastPageRead,
sourceOrder = chapter.sourceOrder,
// KMK -->
dateUpload = min(chapter.dateUpload, dbChapter.dateUpload),
// KMK <--
)
} else {
chapter.copyFrom(dbChapter).let {
when {
dbChapter.read && !it.read -> it.copy(read = true, lastPageRead = dbChapter.lastPageRead)
it.lastPageRead == 0L && dbChapter.lastPageRead != 0L -> it.copy(
lastPageRead = dbChapter.lastPageRead,
)
else -> it
}
}
chapter.copyFrom(dbChapter)
// KMK -->
.copy(id = dbChapter.id)
// KMK <--
.copy(
id = dbChapter.id,
bookmark = chapter.bookmark || dbChapter.bookmark,
dateUpload = min(chapter.dateUpload, dbChapter.dateUpload),
)
// KMK <--
.let {
when {
dbChapter.read && !it.read -> it.copy(read = true, lastPageRead = dbChapter.lastPageRead)
it.lastPageRead == 0L && dbChapter.lastPageRead != 0L -> it.copy(
lastPageRead = dbChapter.lastPageRead,
)
else -> it
}
}
}
}