package eu.friedcutlet.yokan.ui.screens.together import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.getAndUpdate import kotlinx.coroutines.flow.update /** Room code handed in by a deep link; the Together screen's view model joins it. */ object TogetherSession { private val _pendingCode = MutableStateFlow(null) /** Room code handed in by a deep link, consumed by the Together screen. */ val pendingCode: StateFlow = _pendingCode.asStateFlow() fun offerCode(code: String) { _pendingCode.update { code } } /** Returns the deep-linked room code once, clearing it. */ fun takePendingCode(): String? = _pendingCode.getAndUpdate { null } }