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
@@ -27,8 +27,10 @@ import kotlinx.collections.immutable.ImmutableList
sealed class FeedState { sealed class FeedState {
object Loading : FeedState() object Loading : FeedState()
class Loaded(val feed: MutableState<ImmutableList<Note>>, val showHidden: MutableState<Boolean>) : class Loaded(
FeedState() val feed: MutableState<ImmutableList<Note>>,
val showHidden: MutableState<Boolean>,
) : FeedState()
object Empty : FeedState() object Empty : FeedState()
@@ -328,7 +328,9 @@ abstract class FeedViewModel(val localFilter: FeedFilter<Note>) :
_feedContent.update { FeedState.Empty } _feedContent.update { FeedState.Empty }
} else if (currentState is FeedState.Loaded) { } else if (currentState is FeedState.Loaded) {
// updates the current list // updates the current list
currentState.showHidden.value = localFilter.showHiddenKey() if (currentState.showHidden.value != localFilter.showHiddenKey()) {
currentState.showHidden.value = localFilter.showHiddenKey()
}
currentState.feed.value = notes currentState.feed.value = notes
} else { } else {
_feedContent.update { _feedContent.update {