Skip to content

Commit

Permalink
Use rememberSaveable to keep note state across LazyColumns recomposit…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
geovnn committed Jan 4, 2025
1 parent f94feeb commit f1141e6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
Expand Down Expand Up @@ -70,7 +71,7 @@ fun ExpandableRichTextViewer(
nav: INav,
) {
var showFullText by
remember {
rememberSaveable {
val cached = ShowFullTextCache.cache[id]
if (cached == null) {
ShowFullTextCache.cache.put(id, false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.produceState
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Alignment.Companion.Center
Expand Down Expand Up @@ -169,7 +170,7 @@ fun ReactionsRow(
accountViewModel: AccountViewModel,
nav: INav,
) {
val wantsToSeeReactions = remember(baseNote) { mutableStateOf(false) }
val wantsToSeeReactions = rememberSaveable(baseNote) { mutableStateOf(false) }

InnerReactionRow(baseNote, showReactionDetail, addPadding, wantsToSeeReactions, editState, accountViewModel, nav)

Expand Down

0 comments on commit f1141e6

Please sign in to comment.