onByeReceived method
Handles a remote BYE for the given callId.
If the ended call was currentCall, the current call is cleared and the last held call (if any) is automatically unheld and made active.
Implementation
void onByeReceived(String callId) {
if (_currentCall?.callId == callId) {
_currentCall = null;
_currentCallController.add(null);
// Auto-unhold the last held call
final lastHeld = getLastHeldCall();
if (lastHeld != null) {
GlobalLogger().i(
'CallManager: Auto-unholding held call ${lastHeld.callId} after remote BYE for $callId',
);
lastHeld.onHoldUnholdPressed();
_heldCalls.remove(lastHeld);
setCurrentCall(lastHeld);
}
} else {
// It was a held call that got ended remotely
_heldCalls.removeWhere((c) => c.callId == callId);
_notifyHeldCallsChanged();
}
}