Merge 8eadbde323
into a9c7cbf2c4
This commit is contained in:
commit
7e068f1e22
3 changed files with 48 additions and 8 deletions
|
@ -52,6 +52,10 @@ object SettingsDownloadScreen : SearchableSettings {
|
|||
title = stringResource(MR.strings.split_tall_images),
|
||||
subtitle = stringResource(MR.strings.split_tall_images_summary),
|
||||
),
|
||||
Preference.PreferenceItem.SwitchPreference(
|
||||
pref = downloadPreferences.skipDupe(),
|
||||
title = stringResource(R.string.pref_skip_dupe_chapters),
|
||||
),
|
||||
getDeleteChaptersGroup(
|
||||
downloadPreferences = downloadPreferences,
|
||||
categories = allCategories,
|
||||
|
|
|
@ -666,8 +666,22 @@ class MangaScreenModel(
|
|||
) {
|
||||
when (action) {
|
||||
ChapterDownloadAction.START -> {
|
||||
startDownload(items.map { it.chapter }, false)
|
||||
if (items.any { it.downloadState == Download.State.ERROR }) {
|
||||
val filteredItems: List<ChapterItem> = if (downloadPreferences.skipDupe().get()) {
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
@ -686,13 +700,33 @@ class MangaScreenModel(
|
|||
}
|
||||
|
||||
fun runDownloadAction(action: DownloadAction) {
|
||||
val chaptersToDownload = when (action) {
|
||||
DownloadAction.NEXT_1_CHAPTER -> getUnreadChaptersSorted().take(1)
|
||||
DownloadAction.NEXT_5_CHAPTERS -> getUnreadChaptersSorted().take(5)
|
||||
DownloadAction.NEXT_10_CHAPTERS -> getUnreadChaptersSorted().take(10)
|
||||
DownloadAction.NEXT_25_CHAPTERS -> getUnreadChaptersSorted().take(25)
|
||||
DownloadAction.UNREAD_CHAPTERS -> getUnreadChapters()
|
||||
val validChapters = getUnreadChaptersSorted()
|
||||
val amount = when (action) {
|
||||
DownloadAction.NEXT_1_CHAPTER -> 1
|
||||
DownloadAction.NEXT_5_CHAPTERS -> 5
|
||||
DownloadAction.NEXT_10_CHAPTERS -> 10
|
||||
DownloadAction.NEXT_25_CHAPTERS -> 25
|
||||
DownloadAction.UNREAD_CHAPTERS -> validChapters.size
|
||||
}
|
||||
|
||||
val chaptersToDownload: List<Chapter> = kotlin.run {
|
||||
if (downloadPreferences.skipDupe().get()) {
|
||||
mutableListOf<Chapter>().apply {
|
||||
val firstChapter = validChapters.firstOrNull() ?: return
|
||||
for (chapters in validChapters.groupBy { it.chapterNumber }.values) {
|
||||
if (size == amount) break
|
||||
|
||||
add(
|
||||
chapters.find { it.scanlator == firstChapter.scanlator }
|
||||
?: chapters.first(),
|
||||
)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
validChapters.take(amount)
|
||||
}
|
||||
}
|
||||
|
||||
if (chaptersToDownload.isNotEmpty()) {
|
||||
startDownload(chaptersToDownload, false)
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@ class DownloadPreferences(
|
|||
|
||||
fun splitTallImages() = preferenceStore.getBoolean("split_tall_images", false)
|
||||
|
||||
fun skipDupe() = preferenceStore.getBoolean("pref_download_skip_dupe", false)
|
||||
|
||||
fun autoDownloadWhileReading() = preferenceStore.getInt("auto_download_while_reading", 0)
|
||||
|
||||
fun removeAfterReadSlots() = preferenceStore.getInt("remove_after_read_slots", -1)
|
||||
|
|
Reference in a new issue