From b241956ce777fd252cd32a063810011fcd9567d1 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sun, 7 Jul 2024 14:45:26 +0800 Subject: [PATCH] :bug: Fix focus track still exists after that track disappeared --- lib/providers/content/call.dart | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/providers/content/call.dart b/lib/providers/content/call.dart index e243487..b67f097 100644 --- a/lib/providers/content/call.dart +++ b/lib/providers/content/call.dart @@ -34,7 +34,7 @@ class ChatCallProvider extends GetxController { late Room room; late EventsListener listener; - RxList participantTracks = [].obs; + RxList participantTracks = RxList.empty(growable: true); Rx focusTrack = Rx(null); Future checkPermissions() async { @@ -194,7 +194,7 @@ class ChatCallProvider extends GetxController { } } - final newTracks = List.empty(growable: true); + final newTracks = List.empty(growable: true); final mediaTrackList = mediaTracks.values.toList(); mediaTrackList.sort((a, b) { @@ -247,6 +247,15 @@ class ChatCallProvider extends GetxController { } participantTracks.value = newTracks; + + if (focusTrack.value != null) { + final idx = participantTracks.indexWhere( + (x) => x.participant.sid == focusTrack.value!.participant.sid); + if (idx == -1) { + focusTrack.value = null; + } + } + if (focusTrack.value == null) { focusTrack.value = participantTracks.firstOrNull; } else {