mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-17 12:49:19 +01:00
Retain bookmark of readded chapters (#8205)
* Retain bookmark of readded chapters * Fix typo
This commit is contained in:
parent
dbd93cf5d1
commit
a2b21e5ad6
@ -136,11 +136,11 @@ class SyncChaptersWithSource(
|
|||||||
|
|
||||||
val deletedChapterNumbers = TreeSet<Float>()
|
val deletedChapterNumbers = TreeSet<Float>()
|
||||||
val deletedReadChapterNumbers = TreeSet<Float>()
|
val deletedReadChapterNumbers = TreeSet<Float>()
|
||||||
|
val deletedBookmarkedChapterNumbers = TreeSet<Float>()
|
||||||
|
|
||||||
toDelete.forEach { chapter ->
|
toDelete.forEach { chapter ->
|
||||||
if (chapter.read) {
|
if (chapter.read) deletedReadChapterNumbers.add(chapter.chapterNumber)
|
||||||
deletedReadChapterNumbers.add(chapter.chapterNumber)
|
if (chapter.bookmark) deletedBookmarkedChapterNumbers.add(chapter.chapterNumber)
|
||||||
}
|
|
||||||
deletedChapterNumbers.add(chapter.chapterNumber)
|
deletedChapterNumbers.add(chapter.chapterNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,20 +149,19 @@ class SyncChaptersWithSource(
|
|||||||
|
|
||||||
// Date fetch is set in such a way that the upper ones will have bigger value than the lower ones
|
// Date fetch is set in such a way that the upper ones will have bigger value than the lower ones
|
||||||
// Sources MUST return the chapters from most to less recent, which is common.
|
// Sources MUST return the chapters from most to less recent, which is common.
|
||||||
|
|
||||||
var itemCount = toAdd.size
|
var itemCount = toAdd.size
|
||||||
var updatedToAdd = toAdd.map { toAddItem ->
|
var updatedToAdd = toAdd.map { toAddItem ->
|
||||||
var chapter = toAddItem.copy(dateFetch = rightNow + itemCount--)
|
var chapter = toAddItem.copy(dateFetch = rightNow + itemCount--)
|
||||||
|
|
||||||
if (chapter.isRecognizedNumber.not() || chapter.chapterNumber !in deletedChapterNumbers) return@map chapter
|
if (chapter.isRecognizedNumber.not() || chapter.chapterNumber !in deletedChapterNumbers) return@map chapter
|
||||||
|
|
||||||
if (chapter.chapterNumber in deletedReadChapterNumbers) {
|
chapter = chapter.copy(
|
||||||
chapter = chapter.copy(read = true)
|
read = chapter.chapterNumber in deletedReadChapterNumbers,
|
||||||
}
|
bookmark = chapter.chapterNumber in deletedBookmarkedChapterNumbers,
|
||||||
|
)
|
||||||
|
|
||||||
// Try to to use the fetch date of the original entry to not pollute 'Updates' tab
|
// Try to to use the fetch date of the original entry to not pollute 'Updates' tab
|
||||||
val oldDateFetch = deletedChapterNumberDateFetchMap[chapter.chapterNumber]
|
deletedChapterNumberDateFetchMap[chapter.chapterNumber]?.let {
|
||||||
oldDateFetch?.let {
|
|
||||||
chapter = chapter.copy(dateFetch = it)
|
chapter = chapter.copy(dateFetch = it)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user