Merge pull request #2105 from vitorpamplona/claude/fix-call-ringing-bug-aZlur
Fix call state handling to prevent missed cleanup due to StateFlow conflation
This commit is contained in:
@@ -155,7 +155,13 @@ class CallController(
|
|||||||
when (state) {
|
when (state) {
|
||||||
is CallState.IncomingCall -> {
|
is CallState.IncomingCall -> {
|
||||||
withContext(Dispatchers.IO) { audioManager.startRinging() }
|
withContext(Dispatchers.IO) { audioManager.startRinging() }
|
||||||
showIncomingCallNotification(state.callerPubKey)
|
// Launch notification in a separate coroutine so that
|
||||||
|
// long-running network I/O (profile picture download)
|
||||||
|
// does not block the state collector. StateFlow is
|
||||||
|
// conflated — if the collector is suspended when the
|
||||||
|
// state transitions Ended → Idle, the Ended emission
|
||||||
|
// is lost and cleanup/stopRinging never runs.
|
||||||
|
scope.launch { showIncomingCallNotification(state.callerPubKey) }
|
||||||
}
|
}
|
||||||
|
|
||||||
is CallState.Offering -> {
|
is CallState.Offering -> {
|
||||||
@@ -178,7 +184,14 @@ class CallController(
|
|||||||
cleanup()
|
cleanup()
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {}
|
is CallState.Idle -> {
|
||||||
|
// Safety net: ensure ringing and notifications are
|
||||||
|
// stopped even if the Ended state was missed due to
|
||||||
|
// StateFlow conflation.
|
||||||
|
audioManager.stopRinging()
|
||||||
|
audioManager.stopRingbackTone()
|
||||||
|
NotificationUtils.cancelCallNotification(context)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user