fix(reader-chapter): Fix deletion of duplicated chapters when automatically mark as read (#1421)
This commit is contained in:
parent
505c8c23f0
commit
64f12cc6a5
1 changed files with 24 additions and 4 deletions
|
|
@ -761,7 +761,10 @@ class ReaderViewModel @JvmOverloads constructor(
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if deleting option is enabled and nth to last chapter actually exists.
|
* Determines if deleting option is enabled and nth to last chapter actually exists.
|
||||||
* If both conditions are satisfied enqueues chapter for delete
|
* If both conditions are satisfied enqueues chapter for delete.
|
||||||
|
*
|
||||||
|
* This deletes chapters from reading list (filtered, unduplicated if any set).
|
||||||
|
*
|
||||||
* @param currentChapter current chapter, which is going to be marked as read.
|
* @param currentChapter current chapter, which is going to be marked as read.
|
||||||
*/
|
*/
|
||||||
private fun deleteChapterIfNeeded(currentChapter: ReaderChapter) {
|
private fun deleteChapterIfNeeded(currentChapter: ReaderChapter) {
|
||||||
|
|
@ -780,6 +783,23 @@ class ReaderViewModel @JvmOverloads constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// KMK -->
|
||||||
|
/**
|
||||||
|
* Deletes duplicate chapters when `removeAfterReadSlots` = "Last read chapter" (0).
|
||||||
|
*
|
||||||
|
* Ignore the case where `removeAfterReadSlots` > 0 while `skipDupe` = true as we don't know
|
||||||
|
* where the chapters to be deleted are in the filtered [chapterList].
|
||||||
|
*
|
||||||
|
* For the case where `skipDupe` = false, chapters at should be deleted normally by [deleteChapterIfNeeded]
|
||||||
|
* based on the `removeAfterReadSlots` offset while the user is reading sequentially.
|
||||||
|
*/
|
||||||
|
private fun deleteDupChapterIfNeeded(chapterToDelete: ReaderChapter) {
|
||||||
|
val removeAfterReadSlots = downloadPreferences.removeAfterReadSlots().get()
|
||||||
|
if (removeAfterReadSlots != 0) return
|
||||||
|
enqueueDeleteReadChapters(chapterToDelete)
|
||||||
|
}
|
||||||
|
// KMK <--
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the chapter progress (last read page and whether it's read)
|
* Saves the chapter progress (last read page and whether it's read)
|
||||||
* if incognito mode isn't on.
|
* if incognito mode isn't on.
|
||||||
|
|
@ -866,9 +886,9 @@ class ReaderViewModel @JvmOverloads constructor(
|
||||||
chapter.chapterNumber.toFloat() == readerChapter.chapter.chapter_number
|
chapter.chapterNumber.toFloat() == readerChapter.chapter.chapter_number
|
||||||
) {
|
) {
|
||||||
ChapterUpdate(id = chapter.id, read = true)
|
ChapterUpdate(id = chapter.id, read = true)
|
||||||
// SY -->
|
// KMK -->
|
||||||
.also { deleteChapterIfNeeded(ReaderChapter(chapter)) }
|
.also { deleteDupChapterIfNeeded(ReaderChapter(chapter.copy(read = true))) }
|
||||||
// SY <--
|
// KMK <--
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue