Show skeleton on actual Discover filter changes, not just first load

Changing type/catalog/genre didn't clear the previous results, so the
old (now-mismatched) results stayed visible for the entire fetch
duration instead of the skeleton grid — results only ever got replaced
once the new fetch completed. Only clear on a genuine filter change
(compare against the previous DiscoverFiltersUiModel) so a plain tab
revisit with unchanged filters still silently keeps showing cached
results while it revalidates in the background, per the earlier fix.
This commit is contained in:
KhooLy 2026-07-13 23:14:53 +03:00
parent f14b0a383d
commit 83c3e0f3c7
2 changed files with 8 additions and 0 deletions

View file

@ -55,7 +55,11 @@ class AndroidDiscoverDataSource(
}
override suspend fun updateFilters(filters: DiscoverFiltersUiModel) {
val filtersChanged = filters != this.filters.value
this.filters.value = filters
if (filtersChanged) {
homeViewModel.clearDiscoverResults()
}
homeViewModel.loadDiscoverCatalogFilters(filters.contentType, filters.catalogKey)
homeViewModel.discover(
type = filters.contentType,

View file

@ -1002,6 +1002,10 @@ class HomeViewModel @Inject constructor(
)
}
fun clearDiscoverResults() {
_headlessDiscoverResults.value = emptyList()
}
fun discover(type: String, catalogKey: String?, genre: String?, year: String?, rating: Float?, provider: String?, region: String?) {
viewModelScope.launch {
_headlessDiscoverLoading.value = true