diff --git a/apps/multiplatform/common/src/androidMain/kotlin/chat/simplex/common/views/call/CallView.android.kt b/apps/multiplatform/common/src/androidMain/kotlin/chat/simplex/common/views/call/CallView.android.kt index 166f4ec355..22e53af849 100644 --- a/apps/multiplatform/common/src/androidMain/kotlin/chat/simplex/common/views/call/CallView.android.kt +++ b/apps/multiplatform/common/src/androidMain/kotlin/chat/simplex/common/views/call/CallView.android.kt @@ -709,9 +709,11 @@ fun WebRTCView(callCommand: SnapshotStateList, onResponse: (WVAPIM .filterNotNull() .collect { while (callCommand.isNotEmpty()) { - val cmd = callCommand.removeFirst() + val cmd = callCommand.removeFirstOrNull() Log.d(TAG, "WebRTCView LaunchedEffect executing $cmd") - processCommand(wv, cmd) + if (cmd != null) { + processCommand(wv, cmd) + } } } } diff --git a/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/DesktopApp.kt b/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/DesktopApp.kt index 9d747206ab..c9aa5d4989 100644 --- a/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/DesktopApp.kt +++ b/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/DesktopApp.kt @@ -173,7 +173,7 @@ private fun ApplicationScope.AppWindow(closedByError: MutableState) { // Shows toast in insertion order with preferred delay per toast. New one will be shown once previous one expires LaunchedEffect(toast, toasts.size) { delay(toast.second) - simplexWindowState.toasts.removeFirst() + simplexWindowState.toasts.removeFirstOrNull() } } var windowFocused by remember { simplexWindowState.windowFocused } diff --git a/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/views/call/CallView.desktop.kt b/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/views/call/CallView.desktop.kt index e3b0642547..9be10a584b 100644 --- a/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/views/call/CallView.desktop.kt +++ b/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/views/call/CallView.desktop.kt @@ -195,9 +195,11 @@ fun WebRTCController(callCommand: SnapshotStateList, onResponse: ( delay(100) } while (callCommand.isNotEmpty()) { - val cmd = callCommand.removeFirst() + val cmd = callCommand.removeFirstOrNull() Log.d(TAG, "WebRTCController LaunchedEffect executing $cmd") - processCommand(cmd) + if (cmd != null) { + processCommand(cmd) + } } } }