Support skip-downloading-duplicate-read-chapters for merged entries
(cherry picked from commit e19c62a8aef2203eb287ef2f450c95b642f7f2f0)
This commit is contained in:
parent
4f0960309b
commit
10d155b9a0
4 changed files with 25 additions and 22 deletions
|
|
@ -153,7 +153,7 @@ class DomainModule : InjektModule {
|
|||
addFactory { ShouldUpdateDbChapter() }
|
||||
addFactory { SyncChaptersWithSource(get(), get(), get(), get(), get(), get(), get(), get()) }
|
||||
addFactory { GetAvailableScanlators(get()) }
|
||||
addFactory { FilterChaptersForDownload(get(), get(), get()) }
|
||||
addFactory { FilterChaptersForDownload(get(), get(), get(), get()) }
|
||||
|
||||
addSingletonFactory<HistoryRepository> { HistoryRepositoryImpl(get()) }
|
||||
addFactory { GetHistory(get()) }
|
||||
|
|
|
|||
|
|
@ -38,10 +38,7 @@ class MergedSource : HttpSource() {
|
|||
private val updateManga: UpdateManga by injectLazy()
|
||||
private val sourceManager: SourceManager by injectLazy()
|
||||
private val downloadManager: DownloadManager by injectLazy()
|
||||
|
||||
// KMK -->
|
||||
private val filterChaptersForDownload: FilterChaptersForDownload by injectLazy()
|
||||
// KMK <--
|
||||
|
||||
override val id: Long = MERGED_SOURCE_ID
|
||||
|
||||
|
|
@ -133,20 +130,17 @@ class MergedSource : HttpSource() {
|
|||
val (source, loadedManga, reference) = it.load()
|
||||
if (loadedManga != null && reference.getChapterUpdates) {
|
||||
val chapterList = source.getChapterList(loadedManga.toSManga())
|
||||
val chapters =
|
||||
val results =
|
||||
syncChaptersWithSource.await(chapterList, loadedManga, source)
|
||||
// KMK -->
|
||||
// KMK: this should check if user preferences & manga's categories allowed to download
|
||||
// KMK: the checking for skip duplicated-read chapters might not work for merged mangas but won't affect the download
|
||||
val results = filterChaptersForDownload.await(manga, chapters)
|
||||
if (downloadChapters &&
|
||||
// KMK <--
|
||||
reference.downloadChapters
|
||||
) {
|
||||
downloadManager.downloadChapters(
|
||||
loadedManga,
|
||||
results,
|
||||
)
|
||||
|
||||
if (downloadChapters && reference.downloadChapters) {
|
||||
val chaptersToDownload = filterChaptersForDownload.await(manga, results)
|
||||
if (chaptersToDownload.isNotEmpty()) {
|
||||
downloadManager.downloadChapters(
|
||||
loadedManga,
|
||||
chaptersToDownload,
|
||||
)
|
||||
}
|
||||
}
|
||||
results
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1426,12 +1426,9 @@ class MangaScreenModel(
|
|||
private fun downloadNewChapters(chapters: List<Chapter>) {
|
||||
screenModelScope.launchNonCancellable {
|
||||
val manga = successState?.manga ?: return@launchNonCancellable
|
||||
// EXH -->
|
||||
if (manga.isEhBasedManga()) return@launchNonCancellable
|
||||
// EXH <--
|
||||
val chaptersToDownload = filterChaptersForDownload.await(manga, chapters)
|
||||
|
||||
if (chaptersToDownload.isNotEmpty()) {
|
||||
if (chaptersToDownload.isNotEmpty() /* SY --> */ && !manga.isEhBasedManga() /* SY <-- */) {
|
||||
downloadChapters(chaptersToDownload)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
package mihon.domain.chapter.interactor
|
||||
|
||||
import exh.source.MERGED_SOURCE_ID
|
||||
import tachiyomi.domain.category.interactor.GetCategories
|
||||
import tachiyomi.domain.chapter.interactor.GetChaptersByMangaId
|
||||
import tachiyomi.domain.chapter.interactor.GetMergedChaptersByMangaId
|
||||
import tachiyomi.domain.chapter.model.Chapter
|
||||
import tachiyomi.domain.download.service.DownloadPreferences
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
|
|
@ -15,12 +17,14 @@ import tachiyomi.domain.manga.model.Manga
|
|||
*/
|
||||
class FilterChaptersForDownload(
|
||||
private val getChaptersByMangaId: GetChaptersByMangaId,
|
||||
private val getMergedChaptersByMangaId: GetMergedChaptersByMangaId,
|
||||
private val downloadPreferences: DownloadPreferences,
|
||||
private val getCategories: GetCategories,
|
||||
) {
|
||||
|
||||
/**
|
||||
* Determines which chapters of a manga should be downloaded based on user preferences.
|
||||
* This should check if user preferences & manga's categories allowed to download
|
||||
*
|
||||
* @param manga The manga for which chapters may be downloaded.
|
||||
* @param newChapters The list of new chapters available for the manga.
|
||||
|
|
@ -37,7 +41,15 @@ class FilterChaptersForDownload(
|
|||
|
||||
if (!downloadPreferences.downloadNewUnreadChaptersOnly().get()) return newChapters
|
||||
|
||||
val readChapterNumbers = getChaptersByMangaId.await(manga.id)
|
||||
// SY -->
|
||||
val existingChapters = if (manga.source == MERGED_SOURCE_ID) {
|
||||
getMergedChaptersByMangaId.await(manga.id)
|
||||
} else {
|
||||
getChaptersByMangaId.await(manga.id)
|
||||
}
|
||||
|
||||
val readChapterNumbers = existingChapters
|
||||
// SY <--
|
||||
.asSequence()
|
||||
.filter { it.read && it.isRecognizedNumber }
|
||||
.map { it.chapterNumber }
|
||||
|
|
|
|||
Loading…
Reference in a new issue