Maintain correct source order even when receiving new chapters from a sync service (#1360)

* Maintain correct source order even when receiving new chapters from sync service

* Add comma required by build service
This commit is contained in:
Luca Auer 2024-12-17 18:26:11 +01:00 committed by GitHub
parent a25aff7fb0
commit a32c7186e4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 2 deletions

View File

@ -202,6 +202,7 @@ class MangaRestorer(
bookmark = chapter.bookmark || dbChapter.bookmark,
read = chapter.read,
lastPageRead = chapter.lastPageRead,
sourceOrder = chapter.sourceOrder,
)
} else {
chapter.copyFrom(dbChapter).let {
@ -252,7 +253,7 @@ class MangaRestorer(
bookmark = chapter.bookmark,
lastPageRead = chapter.lastPageRead,
chapterNumber = null,
sourceOrder = null,
sourceOrder = if (isSync) chapter.sourceOrder else null,
dateFetch = null,
dateUpload = null,
chapterId = chapter.id,

View File

@ -233,7 +233,12 @@ abstract class SyncService(
localChapter != null && remoteChapter != null -> {
// Use version number to decide which chapter to keep
val chosenChapter = if (localChapter.version >= remoteChapter.version) {
// If there mare more chapter on remote, local sourceOrder will need to be updated to maintain correct source order.
if (localChapters.size < remoteChapters.size) {
localChapter.copy(sourceOrder = remoteChapter.sourceOrder)
} else {
localChapter
}
} else {
remoteChapter
}
@ -500,6 +505,7 @@ abstract class SyncService(
logcat(LogPriority.DEBUG, logTag) { "Using remote saved search: ${remoteSearch.name}." }
remoteSearch
}
else -> {
logcat(LogPriority.DEBUG, logTag) {
"No saved search found for composite key: $compositeKey. Skipping."