Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dev.nucleusframework.composenativetray.menu.impl

import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateListOf
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.graphics.vector.ImageVector
Expand All @@ -22,7 +23,12 @@ import org.jetbrains.compose.resources.painterResource
* functions inside the tray DSL without hoisting them above `application { … }`.
*/
internal class RecordingComposableScope : ComposableTrayMenuScope {
private val ops = mutableListOf<MenuOp>()
// Snapshot-state backed: when only the user's menu lambda recomposes (a state it reads
// changed), the DSL re-records into this list. Readers of snapshot() — the Tray wrapper
// that computes the menu fingerprint — get invalidated by that write and re-record the
// whole menu with a fresh scope, so label/enabled/checked changes reach the native menu
// without the caller disposing the tray (issue #434).
private val ops = mutableStateListOf<MenuOp>()

fun snapshot(): List<MenuOp> = ops.toList()

Expand Down
Loading