Implement scanlator filter (#8803)

* Implement scanlator filter

* Visual improvement to scanlator filter dialog

* Review changes + Bug fixes

Backup not containing filtered chapters and similar issue fix

* Review Changes + Fix SQL query

* Lint mamma mia
This commit is contained in:
AntsyLich
2023-11-05 21:34:35 +06:00
committed by GitHub
parent e6ca54fd04
commit b97aa23548
26 changed files with 462 additions and 33 deletions

View File

@ -9,9 +9,9 @@ class GetChaptersByMangaId(
private val chapterRepository: ChapterRepository,
) {
suspend fun await(mangaId: Long): List<Chapter> {
suspend fun await(mangaId: Long, applyScanlatorFilter: Boolean = false): List<Chapter> {
return try {
chapterRepository.getChapterByMangaId(mangaId)
chapterRepository.getChapterByMangaId(mangaId, applyScanlatorFilter)
} catch (e: Exception) {
logcat(LogPriority.ERROR, e)
emptyList()

View File

@ -14,13 +14,17 @@ interface ChapterRepository {
suspend fun removeChaptersWithIds(chapterIds: List<Long>)
suspend fun getChapterByMangaId(mangaId: Long): List<Chapter>
suspend fun getChapterByMangaId(mangaId: Long, applyScanlatorFilter: Boolean = false): List<Chapter>
suspend fun getScanlatorsByMangaId(mangaId: Long): List<String>
fun getScanlatorsByMangaIdAsFlow(mangaId: Long): Flow<List<String>>
suspend fun getBookmarkedChaptersByMangaId(mangaId: Long): List<Chapter>
suspend fun getChapterById(id: Long): Chapter?
suspend fun getChapterByMangaIdAsFlow(mangaId: Long): Flow<List<Chapter>>
suspend fun getChapterByMangaIdAsFlow(mangaId: Long, applyScanlatorFilter: Boolean = false): Flow<List<Chapter>>
suspend fun getChapterByUrlAndMangaId(url: String, mangaId: Long): Chapter?
}

View File

@ -20,7 +20,7 @@ class GetNextChapters(
suspend fun await(mangaId: Long, onlyUnread: Boolean = true): List<Chapter> {
val manga = getManga.await(mangaId) ?: return emptyList()
val chapters = getChaptersByMangaId.await(mangaId)
val chapters = getChaptersByMangaId.await(mangaId, applyScanlatorFilter = true)
.sortedWith(getChapterSort(manga, sortDescending = false))
return if (onlyUnread) {

View File

@ -24,7 +24,7 @@ class FetchInterval(
} else {
window
}
val chapters = getChaptersByMangaId.await(manga.id)
val chapters = getChaptersByMangaId.await(manga.id, applyScanlatorFilter = true)
val interval = manga.fetchInterval.takeIf { it < 0 } ?: calculateInterval(
chapters,
dateTime.zone,

View File

@ -12,10 +12,10 @@ class GetMangaWithChapters(
private val chapterRepository: ChapterRepository,
) {
suspend fun subscribe(id: Long): Flow<Pair<Manga, List<Chapter>>> {
suspend fun subscribe(id: Long, applyScanlatorFilter: Boolean = false): Flow<Pair<Manga, List<Chapter>>> {
return combine(
mangaRepository.getMangaByIdAsFlow(id),
chapterRepository.getChapterByMangaIdAsFlow(id),
chapterRepository.getChapterByMangaIdAsFlow(id, applyScanlatorFilter),
) { manga, chapters ->
Pair(manga, chapters)
}
@ -25,7 +25,7 @@ class GetMangaWithChapters(
return mangaRepository.getMangaById(id)
}
suspend fun awaitChapters(id: Long): List<Chapter> {
return chapterRepository.getChapterByMangaId(id)
suspend fun awaitChapters(id: Long, applyScanlatorFilter: Boolean = false): List<Chapter> {
return chapterRepository.getChapterByMangaId(id, applyScanlatorFilter)
}
}