2025-01-21 20:29:32 +01:00
|
|
|
package exh.recs
|
|
|
|
|
|
|
|
|
|
import eu.kanade.tachiyomi.source.model.FilterList
|
|
|
|
|
import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceScreenModel
|
|
|
|
|
import exh.recs.sources.RecommendationPagingSource
|
2025-01-24 11:15:59 +01:00
|
|
|
import exh.recs.sources.SourceCatalogue
|
2025-01-21 20:29:32 +01:00
|
|
|
import kotlinx.coroutines.flow.update
|
|
|
|
|
import kotlinx.coroutines.runBlocking
|
|
|
|
|
import tachiyomi.domain.manga.interactor.GetManga
|
|
|
|
|
import uy.kohesive.injekt.Injekt
|
|
|
|
|
import uy.kohesive.injekt.api.get
|
|
|
|
|
|
|
|
|
|
class BrowseRecommendsScreenModel(
|
|
|
|
|
val mangaId: Long,
|
|
|
|
|
sourceId: Long,
|
|
|
|
|
private val recommendationSourceName: String,
|
|
|
|
|
private val getManga: GetManga = Injekt.get(),
|
|
|
|
|
) : BrowseSourceScreenModel(sourceId, null) {
|
|
|
|
|
|
|
|
|
|
val manga = runBlocking { getManga.await(mangaId) }!!
|
|
|
|
|
|
2025-01-24 07:17:17 +01:00
|
|
|
// KMK -->
|
2025-01-24 11:15:59 +01:00
|
|
|
private val sourceCatalogue = SourceCatalogue(sourceId)
|
2025-01-24 07:17:17 +01:00
|
|
|
// KMK <--
|
|
|
|
|
|
2025-01-21 20:29:32 +01:00
|
|
|
val recommendationSource: RecommendationPagingSource
|
2025-01-24 07:17:17 +01:00
|
|
|
get() = RecommendationPagingSource.createSources(
|
|
|
|
|
manga,
|
|
|
|
|
// KMK -->
|
2025-01-24 11:15:59 +01:00
|
|
|
sourceCatalogue,
|
2025-01-24 07:17:17 +01:00
|
|
|
// KMK <--
|
|
|
|
|
).first {
|
2025-01-21 20:29:32 +01:00
|
|
|
it::class.qualifiedName == recommendationSourceName
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun createSourcePagingSource(query: String, filters: FilterList) = recommendationSource
|
|
|
|
|
|
|
|
|
|
init {
|
|
|
|
|
mutableState.update { it.copy(filterable = false) }
|
|
|
|
|
}
|
|
|
|
|
}
|