Skip to content

Commit

Permalink
Maintain correct source order even when receiving new chapters from a…
Browse files Browse the repository at this point in the history
… sync service (#1360)

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

* Add comma required by build service
  • Loading branch information
Lolle2000la authored Dec 17, 2024
1 parent a25aff7 commit a32c718
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
localChapter
// 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
}
Expand Down Expand Up @@ -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."
Expand Down

0 comments on commit a32c718

Please sign in to comment.