Maintain correct source order even when receiving new chapters from a sync service #1360
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1339
Problem description and origin
If chapters are pushed to a sync service from Device A and these new chapters are then received by Device B, the source order of these chapters will be wrong because the existing chapters have not gotten their source order adjusted. This source order usually changes when new chapters get added or old ones get removed, however, as-is local chapters will still be in the order of before with the new chapters now colliding with the old chapters (leading to orders like "Chapter 38" -> "Chapter 43" -> "Chapter 37" -> "Chapter 42" -> ...).
How this PR fixes the problem
The proposed changes now ensure that this corner case for syncing is caught and the
sourceOrder
of the chapters are now in the correct order. I made it so that existing behavior not sync-related should remain unaffected.Screenshot illustrating the problem