Reload saved-searches when screen is navigated back to
This commit is contained in:
parent
1ebbbdb344
commit
7f082b9c97
2 changed files with 19 additions and 4 deletions
|
|
@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.browse.source.feed
|
|||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.animation.Crossfade
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
|
|
@ -76,6 +77,11 @@ class SourceFeedScreen(val sourceId: Long) : Screen() {
|
|||
}
|
||||
}
|
||||
|
||||
LaunchedEffect(navigator.lastItem) {
|
||||
// Reload saved-searches when screen is navigated back to
|
||||
screenModel.reloadSavedSearches()
|
||||
}
|
||||
|
||||
val bulkFavoriteScreenModel = rememberScreenModel { BulkFavoriteScreenModel() }
|
||||
val bulkFavoriteState by bulkFavoriteScreenModel.state.collectAsState()
|
||||
val showingFeedOrderScreen = rememberSaveable { mutableStateOf(false) }
|
||||
|
|
|
|||
|
|
@ -99,10 +99,9 @@ open class SourceFeedScreenModel(
|
|||
// KMK <--
|
||||
|
||||
setFilters(source.getFilterList())
|
||||
screenModelScope.launchIO {
|
||||
val searches = loadSearches()
|
||||
mutableState.update { it.copy(savedSearches = searches) }
|
||||
}
|
||||
// KMK -->
|
||||
reloadSavedSearches()
|
||||
// KMK <--
|
||||
getFeedSavedSearchBySourceId.subscribe(source.id)
|
||||
.onEach {
|
||||
val items = getSourcesToGetFeed(it)
|
||||
|
|
@ -266,6 +265,16 @@ open class SourceFeedScreenModel(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// KMK -->
|
||||
fun reloadSavedSearches() {
|
||||
screenModelScope.launchIO {
|
||||
val searches = loadSearches()
|
||||
mutableState.update { it.copy(savedSearches = searches) }
|
||||
}
|
||||
}
|
||||
// KMK <--
|
||||
|
||||
private suspend fun loadSearches() =
|
||||
getExhSavedSearch.await(source.id, (source as CatalogueSource)::getFilterList)
|
||||
.sortedWith(compareBy(String.CASE_INSENSITIVE_ORDER, EXHSavedSearch::name))
|
||||
|
|
|
|||
Loading…
Reference in a new issue