mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
fix: Scanlator filter not working properly
This commit is contained in:
parent
0e2c336a37
commit
7e1b532f83
6 changed files with 70 additions and 22 deletions
|
@ -186,17 +186,12 @@ class MangaDetailsPresenter(
|
|||
|
||||
private suspend fun getChapters() {
|
||||
val chapters = getChapter.awaitAll(manga.id!!, isScanlatorFiltered()).map { it.toModel() }
|
||||
allChapters = if (!isScanlatorFiltered()) chapters else getChapter.awaitAll(manga.id!!, false).map { it.toModel() }
|
||||
|
||||
// Find downloaded chapters
|
||||
setDownloadedChapters(chapters)
|
||||
allChapterScanlators =
|
||||
if (!isScanlatorFiltered()) {
|
||||
chapters.flatMap { ChapterUtil.getScanlators(it.chapter.scanlator) }
|
||||
} else {
|
||||
getAvailableScanlators.await(manga.id!!)
|
||||
}.toSet()
|
||||
// Store the last emission
|
||||
allChapters = if (!isScanlatorFiltered()) chapters else getChapter.awaitAll(manga.id!!, false).map { it.toModel() }
|
||||
allChapterScanlators = allChapters.mapNotNull { it.chapter.scanlator }.toSet()
|
||||
|
||||
this.chapters = applyChapterFilters(chapters)
|
||||
}
|
||||
|
||||
|
|
|
@ -166,11 +166,9 @@ class ChaptersSortBottomSheet(controller: MangaDetailsController) :
|
|||
binding.filterGroupsButton.setOnClickListener {
|
||||
val scanlators = presenter.allChapterScanlators.toList()
|
||||
val filteredScanlators =
|
||||
(
|
||||
presenter.manga.filtered_scanlators?.let { ChapterUtil.getScanlators(it) }
|
||||
?.toMutableSet()
|
||||
?: mutableSetOf()
|
||||
)
|
||||
presenter.manga.filtered_scanlators?.let { ChapterUtil.getScanlators(it) }.orEmpty()
|
||||
.filter { it in scanlators }
|
||||
.toMutableSet()
|
||||
val preselected = scanlators.map { it in filteredScanlators }.toBooleanArray()
|
||||
var alertDialog: AlertDialog? = null
|
||||
activity.materialAlertDialog()
|
||||
|
|
|
@ -206,10 +206,7 @@ private fun List<Chapter>.filterChaptersByScanlators(manga: Manga): List<Chapter
|
|||
if (manga.filtered_scanlators == null) return this
|
||||
|
||||
return this.filter { chapter ->
|
||||
ChapterUtil.getScanlators(chapter.scanlator)
|
||||
.none { group ->
|
||||
ChapterUtil.getScanlators(manga.filtered_scanlators).contains(group)
|
||||
}
|
||||
!ChapterUtil.getScanlators(manga.filtered_scanlators).contains(chapter.scanlator)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ class ChapterUtil {
|
|||
return chapters.size > 20
|
||||
}
|
||||
|
||||
const val scanlatorSeparator = " & "
|
||||
const val scanlatorSeparator = " [.] "
|
||||
|
||||
fun getScanlators(scanlators: String?): List<String> {
|
||||
if (scanlators.isNullOrBlank()) return emptyList()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue