Fix saved search sometimes using a blank query
This commit is contained in:
parent
8f97dd7fb8
commit
42a93fca5c
@ -2,6 +2,7 @@ package eu.kanade.domain.source.interactor
|
|||||||
|
|
||||||
import eu.kanade.tachiyomi.source.model.FilterList
|
import eu.kanade.tachiyomi.source.model.FilterList
|
||||||
import exh.log.xLogE
|
import exh.log.xLogE
|
||||||
|
import exh.util.nullIfBlank
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.flowOn
|
import kotlinx.coroutines.flow.flowOn
|
||||||
@ -45,7 +46,7 @@ class GetExhSavedSearch(
|
|||||||
return EXHSavedSearch(
|
return EXHSavedSearch(
|
||||||
id = search.id,
|
id = search.id,
|
||||||
name = search.name,
|
name = search.name,
|
||||||
query = search.query.orEmpty(),
|
query = search.query?.nullIfBlank(),
|
||||||
filterList = filters?.let { deserializeFilters(it, getFilterList) },
|
filterList = filters?.let { deserializeFilters(it, getFilterList) },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,6 @@ import eu.kanade.tachiyomi.util.removeCovers
|
|||||||
import exh.metadata.metadata.base.RaisedSearchMetadata
|
import exh.metadata.metadata.base.RaisedSearchMetadata
|
||||||
import exh.source.getMainSource
|
import exh.source.getMainSource
|
||||||
import exh.source.mangaDexSourceIds
|
import exh.source.mangaDexSourceIds
|
||||||
import exh.util.nullIfBlank
|
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.SharingStarted
|
import kotlinx.coroutines.flow.SharingStarted
|
||||||
import kotlinx.coroutines.flow.combine
|
import kotlinx.coroutines.flow.combine
|
||||||
@ -166,7 +165,7 @@ open class BrowseSourceScreenModel(
|
|||||||
if (savedSearchFilters != null) {
|
if (savedSearchFilters != null) {
|
||||||
val savedSearch = runBlocking { getExhSavedSearch.awaitOne(savedSearchFilters) { filters } }
|
val savedSearch = runBlocking { getExhSavedSearch.awaitOne(savedSearchFilters) { filters } }
|
||||||
if (savedSearch != null) {
|
if (savedSearch != null) {
|
||||||
search(query = savedSearch.query.nullIfBlank(), filters = savedSearch.filterList)
|
search(query = savedSearch.query, filters = savedSearch.filterList)
|
||||||
}
|
}
|
||||||
} else if (jsonFilters != null) {
|
} else if (jsonFilters != null) {
|
||||||
runCatching {
|
runCatching {
|
||||||
@ -181,9 +180,6 @@ open class BrowseSourceScreenModel(
|
|||||||
.map { it.sortedWith(compareBy(String.CASE_INSENSITIVE_ORDER, EXHSavedSearch::name)) }
|
.map { it.sortedWith(compareBy(String.CASE_INSENSITIVE_ORDER, EXHSavedSearch::name)) }
|
||||||
.onEach { savedSearches ->
|
.onEach { savedSearches ->
|
||||||
mutableState.update { it.copy(savedSearches = savedSearches) }
|
mutableState.update { it.copy(savedSearches = savedSearches) }
|
||||||
/*withUIContext {
|
|
||||||
filterSheet?.setSavedSearches(savedSearches)
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
.launchIn(coroutineScope)
|
.launchIn(coroutineScope)
|
||||||
}
|
}
|
||||||
@ -529,6 +525,8 @@ open class BrowseSourceScreenModel(
|
|||||||
onToast: (Int) -> Unit,
|
onToast: (Int) -> Unit,
|
||||||
) {
|
) {
|
||||||
coroutineScope.launchIO {
|
coroutineScope.launchIO {
|
||||||
|
if (source !is CatalogueSource) return@launchIO
|
||||||
|
|
||||||
if (search.filterList == null && state.value.filters.isNotEmpty()) {
|
if (search.filterList == null && state.value.filters.isNotEmpty()) {
|
||||||
withUIContext {
|
withUIContext {
|
||||||
onToast(R.string.save_search_invalid)
|
onToast(R.string.save_search_invalid)
|
||||||
@ -536,13 +534,20 @@ open class BrowseSourceScreenModel(
|
|||||||
return@launchIO
|
return@launchIO
|
||||||
}
|
}
|
||||||
|
|
||||||
val allDefault = search.filterList != null && search.filterList == (source as? CatalogueSource)?.getFilterList()
|
val allDefault = search.filterList != null && search.filterList == source.getFilterList()
|
||||||
setDialog(null)
|
setDialog(null)
|
||||||
|
|
||||||
search(
|
mutableState.update {
|
||||||
query = search.query,
|
it.copy(
|
||||||
filters = if (allDefault) null else search.filterList,
|
listing = Listing.Search(
|
||||||
)
|
query = search.query,
|
||||||
|
filters = search.filterList
|
||||||
|
?.takeUnless { allDefault }
|
||||||
|
?: source.getFilterList(),
|
||||||
|
),
|
||||||
|
toolbarQuery = search.query,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,6 @@ import eu.kanade.tachiyomi.source.model.FilterList
|
|||||||
data class EXHSavedSearch(
|
data class EXHSavedSearch(
|
||||||
val id: Long,
|
val id: Long,
|
||||||
val name: String,
|
val name: String,
|
||||||
val query: String,
|
val query: String?,
|
||||||
val filterList: FilterList?,
|
val filterList: FilterList?,
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user