diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/MigrateSearchScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/MigrateSearchScreenModel.kt index 13844638f..73bba479a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/MigrateSearchScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/MigrateSearchScreenModel.kt @@ -30,7 +30,7 @@ class MigrateSearchScreenModel( override fun getEnabledSources(): List { return super.getEnabledSources() - .filter { mutableState.value.sourceFilter != SourceFilter.PinnedOnly || "${it.id}" in pinnedSources } + .filter { state.value.sourceFilter != SourceFilter.PinnedOnly || "${it.id}" in pinnedSources } .sortedWith( compareBy( { it.id != state.value.fromSourceId }, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchScreenModel.kt index 62d4d03bc..944c28f17 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchScreenModel.kt @@ -16,6 +16,6 @@ class GlobalSearchScreenModel( override fun getEnabledSources(): List { return super.getEnabledSources() - .filter { mutableState.value.sourceFilter != SourceFilter.PinnedOnly || "${it.id}" in pinnedSources } + .filter { state.value.sourceFilter != SourceFilter.PinnedOnly || "${it.id}" in pinnedSources } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/SearchScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/SearchScreenModel.kt index dd603ff5a..1c1a2e217 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/SearchScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/SearchScreenModel.kt @@ -29,7 +29,7 @@ import java.util.concurrent.Executors abstract class SearchScreenModel( initialState: State = State(), - private val sourcePreferences: SourcePreferences = Injekt.get(), + sourcePreferences: SourcePreferences = Injekt.get(), private val sourceManager: SourceManager = Injekt.get(), private val extensionManager: ExtensionManager = Injekt.get(), private val networkToLocalManga: NetworkToLocalManga = Injekt.get(), @@ -39,12 +39,14 @@ abstract class SearchScreenModel( private val coroutineDispatcher = Executors.newFixedThreadPool(5).asCoroutineDispatcher() private var searchJob: Job? = null - private val sources by lazy { getSelectedSources() } + private val enabledLanguages = sourcePreferences.enabledLanguages().get() + private val disabledSources = sourcePreferences.disabledSources().get() + protected val pinnedSources = sourcePreferences.pinnedSources().get() + private var lastQuery: String? = null private var lastSourceFilter: SourceFilter? = null protected var extensionFilter: String? = null - protected val pinnedSources = sourcePreferences.pinnedSources().get() private val sortComparator = { map: Map -> compareBy( @@ -66,10 +68,6 @@ abstract class SearchScreenModel( } open fun getEnabledSources(): List { - val enabledLanguages = sourcePreferences.enabledLanguages().get() - val disabledSources = sourcePreferences.disabledSources().get() - val pinnedSources = sourcePreferences.pinnedSources().get() - return sourceManager.getCatalogueSources() .filter { it.lang in enabledLanguages && "${it.id}" !in disabledSources } .sortedWith( @@ -122,7 +120,7 @@ abstract class SearchScreenModel( val initialItems = getSelectedSources().associateWith { SearchItemResult.Loading } updateItems(initialItems) searchJob = ioCoroutineScope.launch { - sources.map { source -> + getSelectedSources().map { source -> async { try { val page = withContext(coroutineDispatcher) {