fix search pull-to-refresh (#4915)

Before this, refreshing the status search would show the loading spinner
but not actually do something (account and hashtag search worked fine).
This commit is contained in:
Konrad Pozniak 2025-02-17 15:16:29 +01:00 committed by GitHub
commit 759902b280
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 3 deletions

View file

@ -60,9 +60,9 @@ class SearchViewModel @Inject constructor(
val activeAccount: AccountEntity?
get() = accountManager.activeAccount
val mediaPreviewEnabled = activeAccount?.mediaPreviewEnabled ?: false
val alwaysShowSensitiveMedia = activeAccount?.alwaysShowSensitiveMedia ?: false
val alwaysOpenSpoiler = activeAccount?.alwaysOpenSpoiler ?: false
val mediaPreviewEnabled = activeAccount?.mediaPreviewEnabled == true
val alwaysShowSensitiveMedia = activeAccount?.alwaysShowSensitiveMedia == true
val alwaysOpenSpoiler = activeAccount?.alwaysOpenSpoiler == true
private val loadedStatuses: MutableList<StatusViewData.Concrete> = mutableListOf()
@ -131,6 +131,10 @@ class SearchViewModel @Inject constructor(
}
}
fun clearStatusCache() {
loadedStatuses.clear()
}
fun expandedChange(statusViewData: StatusViewData.Concrete, expanded: Boolean) {
updateStatusViewData(statusViewData.copy(isExpanded = expanded))
}

View file

@ -147,6 +147,11 @@ class SearchStatusesFragment : SearchFragment<StatusViewData.Concrete>(), Status
return adapter
}
override fun onRefresh() {
viewModel.clearStatusCache()
super.onRefresh()
}
override fun onContentHiddenChange(isShowing: Boolean, position: Int) {
adapter?.peek(position)?.let {
viewModel.contentHiddenChange(it, isShowing)