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