mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-20 09:19:18 +01:00
fix: add skip duplicate chapters logic to ranged downloads
This commit is contained in:
parent
6ad6708230
commit
8eadbde323
@ -580,8 +580,22 @@ class MangaInfoScreenModel(
|
|||||||
) {
|
) {
|
||||||
when (action) {
|
when (action) {
|
||||||
ChapterDownloadAction.START -> {
|
ChapterDownloadAction.START -> {
|
||||||
startDownload(items.map { it.chapter }, false)
|
val filteredItems: List<ChapterItem> = if (downloadPreferences.skipDupe().get()) {
|
||||||
if (items.any { it.downloadState == Download.State.ERROR }) {
|
mutableListOf<ChapterItem>().apply {
|
||||||
|
val firstChapter = items.first().chapter
|
||||||
|
for (chapterItems in items.groupBy { it.chapter.chapterNumber }.values) {
|
||||||
|
add(
|
||||||
|
chapterItems.find { it.chapter.scanlator == firstChapter.scanlator }
|
||||||
|
?: chapterItems.first(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
items
|
||||||
|
}
|
||||||
|
|
||||||
|
startDownload(filteredItems.map { it.chapter }, false)
|
||||||
|
if (filteredItems.any { it.downloadState == Download.State.ERROR }) {
|
||||||
downloadManager.startDownloads()
|
downloadManager.startDownloads()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -613,14 +627,12 @@ class MangaInfoScreenModel(
|
|||||||
if (downloadPreferences.skipDupe().get()) {
|
if (downloadPreferences.skipDupe().get()) {
|
||||||
mutableListOf<Chapter>().apply {
|
mutableListOf<Chapter>().apply {
|
||||||
val firstChapter = validChapters.firstOrNull() ?: return
|
val firstChapter = validChapters.firstOrNull() ?: return
|
||||||
for (chapterEntry in validChapters.groupBy { it.chapterNumber }) {
|
for (chapters in validChapters.groupBy { it.chapterNumber }.values) {
|
||||||
if (size == amount) break
|
if (size == amount) break
|
||||||
if (any { it.chapterNumber == chapterEntry.key }) continue
|
|
||||||
|
|
||||||
add(
|
add(
|
||||||
chapterEntry.value.find { it.id == firstChapter.id }
|
chapters.find { it.scanlator == firstChapter.scanlator }
|
||||||
?: chapterEntry.value.find { it.scanlator == firstChapter.scanlator }
|
?: chapters.first(),
|
||||||
?: chapterEntry.value.first(),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user