Add saved searches to state
This commit is contained in:
parent
7273e48960
commit
19099cd353
app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse
@ -269,7 +269,7 @@ data class BrowseSourceScreen(
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
is BrowseSourceScreenModel.Dialog.CreateSavedSearh -> SavedSearchCreateDialog(
|
is BrowseSourceScreenModel.Dialog.CreateSavedSearch -> SavedSearchCreateDialog(
|
||||||
onDismissRequest = onDismissRequest,
|
onDismissRequest = onDismissRequest,
|
||||||
currentSavedSearches = dialog.currentSavedSearches,
|
currentSavedSearches = dialog.currentSavedSearches,
|
||||||
saveSearch = screenModel::saveSearch,
|
saveSearch = screenModel::saveSearch,
|
||||||
|
@ -78,6 +78,7 @@ import eu.kanade.tachiyomi.util.removeCovers
|
|||||||
import eu.kanade.tachiyomi.util.system.logcat
|
import eu.kanade.tachiyomi.util.system.logcat
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
import eu.kanade.tachiyomi.util.system.toast
|
||||||
import exh.metadata.metadata.base.RaisedSearchMetadata
|
import exh.metadata.metadata.base.RaisedSearchMetadata
|
||||||
|
import exh.savedsearches.EXHSavedSearch
|
||||||
import exh.savedsearches.models.SavedSearch
|
import exh.savedsearches.models.SavedSearch
|
||||||
import exh.source.getMainSource
|
import exh.source.getMainSource
|
||||||
import exh.util.nullIfBlank
|
import exh.util.nullIfBlank
|
||||||
@ -209,9 +210,10 @@ open class BrowseSourceScreenModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
getExhSavedSearch.subscribe(source.id, source::getFilterList)
|
getExhSavedSearch.subscribe(source.id, source::getFilterList)
|
||||||
.onEach {
|
.onEach { savedSearches ->
|
||||||
|
mutableState.update { it.copy(savedSearches = savedSearches) }
|
||||||
withUIContext {
|
withUIContext {
|
||||||
filterSheet?.setSavedSearches(it)
|
filterSheet?.setSavedSearches(savedSearches)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.launchIn(coroutineScope)
|
.launchIn(coroutineScope)
|
||||||
@ -472,7 +474,7 @@ open class BrowseSourceScreenModel(
|
|||||||
// SY -->
|
// SY -->
|
||||||
navigator = navigator,
|
navigator = navigator,
|
||||||
source = source,
|
source = source,
|
||||||
searches = emptyList(),
|
searches = state.savedSearches,
|
||||||
// SY <--
|
// SY <--
|
||||||
onFilterClicked = { search(filters = state.filters) },
|
onFilterClicked = { search(filters = state.filters) },
|
||||||
onResetClicked = {
|
onResetClicked = {
|
||||||
@ -483,7 +485,7 @@ open class BrowseSourceScreenModel(
|
|||||||
onSaveClicked = {
|
onSaveClicked = {
|
||||||
coroutineScope.launchIO {
|
coroutineScope.launchIO {
|
||||||
val names = loadSearches().map { it.name }
|
val names = loadSearches().map { it.name }
|
||||||
mutableState.update { it.copy(dialog = Dialog.CreateSavedSearh(names)) }
|
mutableState.update { it.copy(dialog = Dialog.CreateSavedSearch(names)) }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onSavedSearchClicked = { idOfSearch ->
|
onSavedSearchClicked = { idOfSearch ->
|
||||||
@ -546,7 +548,7 @@ open class BrowseSourceScreenModel(
|
|||||||
// SY -->
|
// SY -->
|
||||||
object FailedToLoadSavedSearch : Dialog()
|
object FailedToLoadSavedSearch : Dialog()
|
||||||
data class DeleteSavedSearch(val idToDelete: Long, val name: String) : Dialog()
|
data class DeleteSavedSearch(val idToDelete: Long, val name: String) : Dialog()
|
||||||
data class CreateSavedSearh(val currentSavedSearches: List<String>) : Dialog()
|
data class CreateSavedSearch(val currentSavedSearches: List<String>) : Dialog()
|
||||||
// SY <--
|
// SY <--
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -556,6 +558,9 @@ open class BrowseSourceScreenModel(
|
|||||||
val filters: FilterList = FilterList(),
|
val filters: FilterList = FilterList(),
|
||||||
val toolbarQuery: String? = null,
|
val toolbarQuery: String? = null,
|
||||||
val dialog: Dialog? = null,
|
val dialog: Dialog? = null,
|
||||||
|
// SY -->
|
||||||
|
val savedSearches: List<EXHSavedSearch> = emptyList(),
|
||||||
|
// SY <--
|
||||||
) {
|
) {
|
||||||
val filterItems = filters.toItems()
|
val filterItems = filters.toItems()
|
||||||
val isUserQuery = currentFilter is Filter.UserInput && !currentFilter.query.isNullOrEmpty()
|
val isUserQuery = currentFilter is Filter.UserInput && !currentFilter.query.isNullOrEmpty()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user