File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed
voyager-core/src/commonMain/kotlin/cafe/adriel/voyager/core/stack Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import androidx.compose.runtime.saveable.Saver
99import androidx.compose.runtime.saveable.listSaver
1010import androidx.compose.runtime.saveable.rememberSaveable
1111import androidx.compose.runtime.setValue
12+ import androidx.compose.runtime.snapshots.Snapshot
1213import androidx.compose.runtime.snapshots.SnapshotStateList
1314import androidx.compose.runtime.toMutableStateList
1415
@@ -111,15 +112,19 @@ public class SnapshotStateStack<Item>(
111112 }
112113
113114 public override infix fun replaceAll (item : Item ) {
114- stateStack.clear()
115- stateStack + = item
116- lastEvent = StackEvent .Replace
115+ Snapshot .withMutableSnapshot {
116+ stateStack.clear()
117+ stateStack + = item
118+ lastEvent = StackEvent .Replace
119+ }
117120 }
118121
119122 public override infix fun replaceAll (items : List <Item >) {
120- stateStack.clear()
121- stateStack + = items
122- lastEvent = StackEvent .Replace
123+ Snapshot .withMutableSnapshot {
124+ stateStack.clear()
125+ stateStack + = items
126+ lastEvent = StackEvent .Replace
127+ }
123128 }
124129
125130 public override fun pop (): Boolean =
You can’t perform that action at this time.
0 commit comments