diff --git a/demo-app/src/main/kotlin/io/getstream/video/android/ui/call/AvailableDeviceMenu.kt b/demo-app/src/main/kotlin/io/getstream/video/android/ui/call/AvailableDeviceMenu.kt index 9571749bf2..86a1eeede5 100644 --- a/demo-app/src/main/kotlin/io/getstream/video/android/ui/call/AvailableDeviceMenu.kt +++ b/demo-app/src/main/kotlin/io/getstream/video/android/ui/call/AvailableDeviceMenu.kt @@ -29,7 +29,6 @@ import androidx.compose.material.Card import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -37,6 +36,7 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.unit.IntOffset import androidx.compose.ui.unit.dp import androidx.compose.ui.window.Popup +import androidx.lifecycle.compose.collectAsStateWithLifecycle import io.getstream.video.android.compose.theme.VideoTheme import io.getstream.video.android.core.Call import kotlinx.coroutines.delay @@ -47,7 +47,7 @@ fun AvailableDeviceMenu( onDismissed: () -> Unit, ) { val context = LocalContext.current - val availableDevices by call.microphone.devices.collectAsState() + val availableDevices by call.microphone.devices.collectAsStateWithLifecycle() LaunchedEffect(key1 = availableDevices) { delay(3000) diff --git a/demo-app/src/main/kotlin/io/getstream/video/android/ui/call/CallScreen.kt b/demo-app/src/main/kotlin/io/getstream/video/android/ui/call/CallScreen.kt index f006d6b295..9f6cfd6e16 100644 --- a/demo-app/src/main/kotlin/io/getstream/video/android/ui/call/CallScreen.kt +++ b/demo-app/src/main/kotlin/io/getstream/video/android/ui/call/CallScreen.kt @@ -33,7 +33,6 @@ import androidx.compose.material.Text import androidx.compose.material.rememberModalBottomSheetState import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.mutableStateListOf @@ -47,6 +46,7 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +import androidx.lifecycle.compose.collectAsStateWithLifecycle import io.getstream.chat.android.ui.common.state.messages.list.MessageItemState import io.getstream.video.android.BuildConfig import io.getstream.video.android.compose.theme.VideoTheme @@ -77,9 +77,9 @@ fun CallScreen( onUserLeaveCall: () -> Unit = {}, ) { val context = LocalContext.current - val isCameraEnabled by call.camera.isEnabled.collectAsState() - val isMicrophoneEnabled by call.microphone.isEnabled.collectAsState() - val speakingWhileMuted by call.state.speakingWhileMuted.collectAsState() + val isCameraEnabled by call.camera.isEnabled.collectAsStateWithLifecycle() + val isMicrophoneEnabled by call.microphone.isEnabled.collectAsStateWithLifecycle() + val speakingWhileMuted by call.state.speakingWhileMuted.collectAsStateWithLifecycle() var isShowingSettingMenu by remember { mutableStateOf(false) } var isShowingLayoutChooseMenu by remember { mutableStateOf(false) } var isShowingReactionsMenu by remember { mutableStateOf(false) } @@ -95,7 +95,7 @@ fun CallScreen( val scope = rememberCoroutineScope() val messageScope = rememberCoroutineScope() - val callState by call.state.connection.collectAsState() + val callState by call.state.connection.collectAsStateWithLifecycle() LaunchedEffect(key1 = callState) { if (callState == RealtimeConnection.Disconnected) { diff --git a/demo-app/src/main/kotlin/io/getstream/video/android/ui/call/SettingsMenu.kt b/demo-app/src/main/kotlin/io/getstream/video/android/ui/call/SettingsMenu.kt index 6dcf2441a4..524fcbc8bc 100644 --- a/demo-app/src/main/kotlin/io/getstream/video/android/ui/call/SettingsMenu.kt +++ b/demo-app/src/main/kotlin/io/getstream/video/android/ui/call/SettingsMenu.kt @@ -34,7 +34,6 @@ import androidx.compose.material.Card import androidx.compose.material.Icon import androidx.compose.material.Text import androidx.compose.runtime.Composable -import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Alignment @@ -44,6 +43,7 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.IntOffset import androidx.compose.ui.unit.dp import androidx.compose.ui.window.Popup +import androidx.lifecycle.compose.collectAsStateWithLifecycle import io.getstream.video.android.compose.theme.VideoTheme import io.getstream.video.android.core.Call import io.getstream.video.android.core.call.audio.AudioFilter @@ -75,7 +75,7 @@ internal fun SettingsMenu( }, ) - val isScreenSharing by call.screenShare.isEnabled.collectAsState() + val isScreenSharing by call.screenShare.isEnabled.collectAsStateWithLifecycle() val screenShareButtonText = if (isScreenSharing) { "Stop screen-sharing" } else { diff --git a/stream-video-android-ui-compose/src/main/kotlin/io/getstream/video/android/compose/ui/components/livestream/LivestreamPlayer.kt b/stream-video-android-ui-compose/src/main/kotlin/io/getstream/video/android/compose/ui/components/livestream/LivestreamPlayer.kt index ac964cbb82..9a336413c9 100644 --- a/stream-video-android-ui-compose/src/main/kotlin/io/getstream/video/android/compose/ui/components/livestream/LivestreamPlayer.kt +++ b/stream-video-android-ui-compose/src/main/kotlin/io/getstream/video/android/compose/ui/components/livestream/LivestreamPlayer.kt @@ -20,11 +20,11 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.BoxScope import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.runtime.Composable -import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.tooling.preview.Preview +import androidx.lifecycle.compose.collectAsStateWithLifecycle import io.getstream.video.android.compose.theme.VideoTheme import io.getstream.video.android.core.Call import io.getstream.video.android.mock.StreamPreviewDataUtils @@ -61,7 +61,7 @@ public fun LivestreamPlayer( LivestreamPlayerOverlay(call = call) }, ) { - val backstage by call.state.backstage.collectAsState() + val backstage by call.state.backstage.collectAsStateWithLifecycle() Box( modifier = modifier.fillMaxSize(),