diff --git a/lib/ui/screens/call_screen.dart b/lib/ui/screens/call_screen.dart index 4eb8d88..c3e9e9f 100644 --- a/lib/ui/screens/call_screen.dart +++ b/lib/ui/screens/call_screen.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:comunic/helpers/calls_helper.dart'; import 'package:comunic/helpers/conversations_helper.dart'; import 'package:comunic/helpers/events_helper.dart'; @@ -229,8 +231,10 @@ class _CallScreenState extends SafeState { peerConnection.onIceConnectionState = (c) { print("New connection state: $c"); - if (c == RTCIceConnectionState.RTCIceConnectionStateConnected) - CallsHelper.markPeerReady(convID); + if (c == RTCIceConnectionState.RTCIceConnectionStateConnected) { + // Add a delay of two seconds to avoid racing + Timer(Duration(seconds: 2), () => CallsHelper.markPeerReady(convID)); + } }; peerConnection.onSignalingState = (c) => print("New signaling state: $c");