mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-14 20:39:59 -05:00
Use correct sources when triggering new global search
Actually fixes #9724
This commit is contained in:
parent
262ce3473f
commit
3f868c0435
3 changed files with 8 additions and 10 deletions
|
@ -30,7 +30,7 @@ class MigrateSearchScreenModel(
|
|||
|
||||
override fun getEnabledSources(): List<CatalogueSource> {
|
||||
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 },
|
||||
|
|
|
@ -16,6 +16,6 @@ class GlobalSearchScreenModel(
|
|||
|
||||
override fun getEnabledSources(): List<CatalogueSource> {
|
||||
return super.getEnabledSources()
|
||||
.filter { mutableState.value.sourceFilter != SourceFilter.PinnedOnly || "${it.id}" in pinnedSources }
|
||||
.filter { state.value.sourceFilter != SourceFilter.PinnedOnly || "${it.id}" in pinnedSources }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<CatalogueSource, SearchItemResult> ->
|
||||
compareBy<CatalogueSource>(
|
||||
|
@ -66,10 +68,6 @@ abstract class SearchScreenModel(
|
|||
}
|
||||
|
||||
open fun getEnabledSources(): List<CatalogueSource> {
|
||||
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) {
|
||||
|
|
Loading…
Reference in a new issue