Avoids changing the showhidden value all the time, triggering recompositions.

This commit is contained in:
Vitor Pamplona 2024-03-02 12:35:04 -05:00
parent 861ad218c8
commit 6725114b48
2 changed files with 7 additions and 3 deletions

View File

@ -27,8 +27,10 @@ import kotlinx.collections.immutable.ImmutableList
sealed class FeedState {
object Loading : FeedState()
class Loaded(val feed: MutableState<ImmutableList<Note>>, val showHidden: MutableState<Boolean>) :
FeedState()
class Loaded(
val feed: MutableState<ImmutableList<Note>>,
val showHidden: MutableState<Boolean>,
) : FeedState()
object Empty : FeedState()

View File

@ -328,7 +328,9 @@ abstract class FeedViewModel(val localFilter: FeedFilter<Note>) :
_feedContent.update { FeedState.Empty }
} else if (currentState is FeedState.Loaded) {
// updates the current list
currentState.showHidden.value = localFilter.showHiddenKey()
if (currentState.showHidden.value != localFilter.showHiddenKey()) {
currentState.showHidden.value = localFilter.showHiddenKey()
}
currentState.feed.value = notes
} else {
_feedContent.update {