Restore chapter's bookmark & oldest dateUpload from backup (#659)
This commit is contained in:
parent
4c7563294d
commit
4a0c1384d0
1 changed files with 20 additions and 11 deletions
|
|
@ -31,6 +31,7 @@ import uy.kohesive.injekt.api.get
|
||||||
import java.time.ZonedDateTime
|
import java.time.ZonedDateTime
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
|
import kotlin.math.min
|
||||||
|
|
||||||
class MangaRestorer(
|
class MangaRestorer(
|
||||||
private var isSync: Boolean = false,
|
private var isSync: Boolean = false,
|
||||||
|
|
@ -206,20 +207,28 @@ class MangaRestorer(
|
||||||
read = chapter.read,
|
read = chapter.read,
|
||||||
lastPageRead = chapter.lastPageRead,
|
lastPageRead = chapter.lastPageRead,
|
||||||
sourceOrder = chapter.sourceOrder,
|
sourceOrder = chapter.sourceOrder,
|
||||||
|
// KMK -->
|
||||||
|
dateUpload = min(chapter.dateUpload, dbChapter.dateUpload),
|
||||||
|
// KMK <--
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
chapter.copyFrom(dbChapter).let {
|
chapter.copyFrom(dbChapter)
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// KMK -->
|
// KMK -->
|
||||||
.copy(id = dbChapter.id)
|
.copy(
|
||||||
// KMK <--
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue