fix: prevent call screen from closing before state transitions
When initiateCall() runs async (Dispatchers.IO), navigation to the ActiveCall screen happens before CallManager state changes from Idle to Offering. The CallScreen sees Idle and immediately calls onCallEnded() → popBack(), causing the screen to flash and disappear. Fix: CallScreen now waits 500ms on Idle before popping back. If the state transitions to Offering within that window (normal case), the screen stays. If it's still Idle after 500ms (no call in progress), it pops back as before. https://claude.ai/code/session_017hZm7yu7CzmcQgZGSaqSXS
This commit is contained in:
@@ -107,7 +107,14 @@ fun CallScreen(
|
||||
Box(modifier = Modifier.fillMaxSize()) {
|
||||
when (val state = callState) {
|
||||
is CallState.Idle -> {
|
||||
LaunchedEffect(Unit) { onCallEnded() }
|
||||
// Wait briefly — initiateCall runs async and state may not have
|
||||
// transitioned yet when navigating to this screen
|
||||
LaunchedEffect(Unit) {
|
||||
delay(500)
|
||||
if (callManager.state.value is CallState.Idle) {
|
||||
onCallEnded()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is CallState.Offering -> {
|
||||
|
||||
Reference in New Issue
Block a user