mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-11-03 23:58:55 +01:00 
			
		
		
		
	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:
		@@ -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()
 | 
			
		||||
 
 | 
			
		||||
@@ -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?
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -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) {
 | 
			
		||||
 
 | 
			
		||||
@@ -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,
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user