Skip to content

Commit 573f1cf

Browse files
Lolle2000lacuong-tran
authored andcommitted
Maintain correct source order even when receiving new chapters from a sync service (jobobby04/TachiyomiSY#1360)
* Maintain correct source order even when receiving new chapters from sync service * Add comma required by build service (cherry picked from commit a32c7186e43fe616c5956f04c0cef50b450d97c1)
1 parent 904b357 commit 573f1cf

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

app/src/main/java/eu/kanade/tachiyomi/data/backup/restore/restorers/MangaRestorer.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ class MangaRestorer(
205205
bookmark = chapter.bookmark || dbChapter.bookmark,
206206
read = chapter.read,
207207
lastPageRead = chapter.lastPageRead,
208+
sourceOrder = chapter.sourceOrder,
208209
)
209210
} else {
210211
chapter.copyFrom(dbChapter).let {
@@ -255,7 +256,7 @@ class MangaRestorer(
255256
bookmark = chapter.bookmark,
256257
lastPageRead = chapter.lastPageRead,
257258
chapterNumber = null,
258-
sourceOrder = null,
259+
sourceOrder = if (isSync) chapter.sourceOrder else null,
259260
dateFetch = null,
260261
dateUpload = null,
261262
chapterId = chapter.id,

app/src/main/java/eu/kanade/tachiyomi/data/sync/service/SyncService.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,12 @@ abstract class SyncService(
233233
localChapter != null && remoteChapter != null -> {
234234
// Use version number to decide which chapter to keep
235235
val chosenChapter = if (localChapter.version >= remoteChapter.version) {
236-
localChapter
236+
// If there mare more chapter on remote, local sourceOrder will need to be updated to maintain correct source order.
237+
if (localChapters.size < remoteChapters.size) {
238+
localChapter.copy(sourceOrder = remoteChapter.sourceOrder)
239+
} else {
240+
localChapter
241+
}
237242
} else {
238243
remoteChapter
239244
}
@@ -500,6 +505,7 @@ abstract class SyncService(
500505
logcat(LogPriority.DEBUG, logTag) { "Using remote saved search: ${remoteSearch.name}." }
501506
remoteSearch
502507
}
508+
503509
else -> {
504510
logcat(LogPriority.DEBUG, logTag) {
505511
"No saved search found for composite key: $compositeKey. Skipping."

0 commit comments

Comments
 (0)