feat(video_calls): call ended push, recall button for message

This commit is contained in:
misha
2026-06-30 16:11:18 +03:00
parent c0c7e2e658
commit f493e07f9f
30 changed files with 671 additions and 83 deletions

View File

@@ -1,6 +1,7 @@
import 'dart:async';
import 'package:eatvio_app/core/app_router.dart';
import 'package:eatvio_app/core/device/device_hw_id_provider.dart';
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/widgets/show_error_dialog.dart';
import 'package:eatvio_app/features/video_calls/managers/video_call_manager_snapshot.dart';
@@ -56,7 +57,6 @@ class VideoCallManager {
lk.Room? _room;
lk.EventsListener<lk.RoomEvent>? _roomEventsListener;
OverlayEntry? _poorConnectionEntry;
Timer? _mutedMicPollTimer;
DateTime? _lastMutedMicOverlayAt;
bool _recordingOverlayScheduled = false;
@@ -64,6 +64,7 @@ class VideoCallManager {
num? _lastMutedMicTotalEnergy;
bool _liveKitDisposed = true;
bool _callEndedNotified = true;
final Set<String> _callAcceptNotifiedConversationUuids = {};
bool _callStageEntered = false;
bool _joinInProgress = false;
bool _counterpartJoinedNotified = false;
@@ -409,6 +410,27 @@ class VideoCallManager {
_emitSnapshot(VideoCallManagerSnapshot.initial);
}
/// Notifies backend that this device accepted an incoming call so ringing
/// stops on the user's other devices.
Future<void> notifyIncomingCallAccepted(String conversationUuid) async {
final uuid = conversationUuid.trim();
if (uuid.isEmpty) return;
if (_callAcceptNotifiedConversationUuids.contains(uuid)) return;
final hwId = (await DeviceHwIdProvider.current())?.trim();
if (hwId == null || hwId.length < 8) return;
_callAcceptNotifiedConversationUuids.add(uuid);
try {
await _videoCallRepository.notifyCallAccepted(
conversationUuid: uuid,
hwId: hwId,
);
} catch (_) {
_callAcceptNotifiedConversationUuids.remove(uuid);
}
}
/// Decline from incoming UI before joining the LiveKit room.
Future<void> declineIncomingCall(String conversationUuid) async {
final uuid = conversationUuid.trim();
@@ -716,6 +738,7 @@ class VideoCallManager {
_counterpartJoinedNotified = false;
_roomConnectFuture = null;
_clearPreparedConnectionCredentials();
_callAcceptNotifiedConversationUuids.clear();
_emitSnapshot(
_snapshot.copyWith(
counterpartPresentInLobby: false,
@@ -736,11 +759,7 @@ class VideoCallManager {
if (listener != null) {
unawaited(listener.dispose());
}
final poor = _poorConnectionEntry;
_poorConnectionEntry = null;
if (poor != null && poor.mounted) {
poor.remove();
}
VideoCallTopOverlay.hidePoorConnectionIcon();
}
void _startMutedMicPollTimer() {
@@ -775,6 +794,7 @@ class VideoCallManager {
_abortingLiveKitAutoReconnect = true;
try {
_emitSnapshot(_snapshot.copyWith(linkIssue: VideoCallLinkIssue.lost));
VideoCallTopOverlay.hidePoorConnectionIcon();
final room = _room;
if (room != null &&
room.connectionState != lk.ConnectionState.disconnected) {
@@ -822,29 +842,18 @@ class VideoCallManager {
}
void _syncPoorConnectionOverlay(lk.ConnectionQuality q) {
if (_liveKitDisposed || !_callStageEntered) {
VideoCallTopOverlay.hidePoorConnectionIcon();
return;
}
final ctx = _navigatorContext;
if (ctx == null) return;
final bad =
q == lk.ConnectionQuality.poor || q == lk.ConnectionQuality.lost;
if (bad) {
final existing = _poorConnectionEntry;
if (existing != null && existing.mounted) return;
_poorConnectionEntry = null;
final entry = VideoCallTopOverlay.insertBanner(
ctx,
message: S.of(ctx).video_call_poor_connection,
backgroundColor: appTheme.strongRed,
svgAsset: VideoCallTopOverlay.poorConnectionSvg,
);
if (entry.mounted) {
_poorConnectionEntry = entry;
}
VideoCallTopOverlay.showPoorConnectionIcon(ctx);
} else {
final e = _poorConnectionEntry;
if (e != null && e.mounted) {
e.remove();
}
_poorConnectionEntry = null;
VideoCallTopOverlay.hidePoorConnectionIcon();
}
}