mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-26 23:18:17 +03: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> {
|
override fun getEnabledSources(): List<CatalogueSource> {
|
||||||
return super.getEnabledSources()
|
return super.getEnabledSources()
|
||||||
.filter { mutableState.value.sourceFilter != SourceFilter.PinnedOnly || "${it.id}" in pinnedSources }
|
.filter { state.value.sourceFilter != SourceFilter.PinnedOnly || "${it.id}" in pinnedSources }
|
||||||
.sortedWith(
|
.sortedWith(
|
||||||
compareBy(
|
compareBy(
|
||||||
{ it.id != state.value.fromSourceId },
|
{ it.id != state.value.fromSourceId },
|
||||||
|
|
|
@ -16,6 +16,6 @@ class GlobalSearchScreenModel(
|
||||||
|
|
||||||
override fun getEnabledSources(): List<CatalogueSource> {
|
override fun getEnabledSources(): List<CatalogueSource> {
|
||||||
return super.getEnabledSources()
|
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(
|
abstract class SearchScreenModel(
|
||||||
initialState: State = State(),
|
initialState: State = State(),
|
||||||
private val sourcePreferences: SourcePreferences = Injekt.get(),
|
sourcePreferences: SourcePreferences = Injekt.get(),
|
||||||
private val sourceManager: SourceManager = Injekt.get(),
|
private val sourceManager: SourceManager = Injekt.get(),
|
||||||
private val extensionManager: ExtensionManager = Injekt.get(),
|
private val extensionManager: ExtensionManager = Injekt.get(),
|
||||||
private val networkToLocalManga: NetworkToLocalManga = Injekt.get(),
|
private val networkToLocalManga: NetworkToLocalManga = Injekt.get(),
|
||||||
|
@ -39,12 +39,14 @@ abstract class SearchScreenModel(
|
||||||
private val coroutineDispatcher = Executors.newFixedThreadPool(5).asCoroutineDispatcher()
|
private val coroutineDispatcher = Executors.newFixedThreadPool(5).asCoroutineDispatcher()
|
||||||
private var searchJob: Job? = null
|
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 lastQuery: String? = null
|
||||||
private var lastSourceFilter: SourceFilter? = null
|
private var lastSourceFilter: SourceFilter? = null
|
||||||
|
|
||||||
protected var extensionFilter: String? = null
|
protected var extensionFilter: String? = null
|
||||||
protected val pinnedSources = sourcePreferences.pinnedSources().get()
|
|
||||||
|
|
||||||
private val sortComparator = { map: Map<CatalogueSource, SearchItemResult> ->
|
private val sortComparator = { map: Map<CatalogueSource, SearchItemResult> ->
|
||||||
compareBy<CatalogueSource>(
|
compareBy<CatalogueSource>(
|
||||||
|
@ -66,10 +68,6 @@ abstract class SearchScreenModel(
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun getEnabledSources(): List<CatalogueSource> {
|
open fun getEnabledSources(): List<CatalogueSource> {
|
||||||
val enabledLanguages = sourcePreferences.enabledLanguages().get()
|
|
||||||
val disabledSources = sourcePreferences.disabledSources().get()
|
|
||||||
val pinnedSources = sourcePreferences.pinnedSources().get()
|
|
||||||
|
|
||||||
return sourceManager.getCatalogueSources()
|
return sourceManager.getCatalogueSources()
|
||||||
.filter { it.lang in enabledLanguages && "${it.id}" !in disabledSources }
|
.filter { it.lang in enabledLanguages && "${it.id}" !in disabledSources }
|
||||||
.sortedWith(
|
.sortedWith(
|
||||||
|
@ -122,7 +120,7 @@ abstract class SearchScreenModel(
|
||||||
val initialItems = getSelectedSources().associateWith { SearchItemResult.Loading }
|
val initialItems = getSelectedSources().associateWith { SearchItemResult.Loading }
|
||||||
updateItems(initialItems)
|
updateItems(initialItems)
|
||||||
searchJob = ioCoroutineScope.launch {
|
searchJob = ioCoroutineScope.launch {
|
||||||
sources.map { source ->
|
getSelectedSources().map { source ->
|
||||||
async {
|
async {
|
||||||
try {
|
try {
|
||||||
val page = withContext(coroutineDispatcher) {
|
val page = withContext(coroutineDispatcher) {
|
||||||
|
|
Loading…
Reference in a new issue