-
Notifications
You must be signed in to change notification settings - Fork 495
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve issue where read chapters were still being downloaded during …
…manual manga fetch
- Loading branch information
Showing
3 changed files
with
41 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
app/src/main/java/mihon/core/chapters/utils/FilterChaptersToDownload.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package mihon.core.chapters.utils | ||
|
||
import mihon.domain.chapter.interactor.GetReadChapterCountByMangaIdAndChapterNumber | ||
import tachiyomi.domain.chapter.model.Chapter | ||
import tachiyomi.domain.download.service.DownloadPreferences | ||
import tachiyomi.domain.manga.model.Manga | ||
|
||
/** | ||
* Filters the list of chapters based on the user's download preferences. | ||
* | ||
* This function checks the user's preference for downloading only unread chapters. If the | ||
* preference is enabled, it filters the chapters to include only those that haven't been read. | ||
* Otherwise, it returns the original list of chapters. | ||
* | ||
* @param manga The manga to which the chapters belong. | ||
* @param getReadChapterCount A function to get the count of times a chapter has been read. | ||
* @param downloadPreferences User preferences related to downloading chapters. | ||
* @return A list of chapters filtered according to the download preferences. If the user prefers to download only | ||
* unread chapters, the list will contain only unread chapters. Otherwise, it will return the original list of chapters. | ||
*/ | ||
suspend fun List<Chapter>.filterChaptersToDownload( | ||
manga: Manga, | ||
getReadChapterCount: GetReadChapterCountByMangaIdAndChapterNumber, | ||
downloadPreferences: DownloadPreferences, | ||
): List<Chapter> { | ||
val onlyDownloadUnreadChapters = downloadPreferences.downloadUnreadChaptersOnly().get() | ||
|
||
return if (onlyDownloadUnreadChapters) { | ||
this.filter { getReadChapterCount.await(manga.id, it.chapterNumber) == 0L } | ||
} else { | ||
this | ||
} | ||
} |