From 9ffac3b0ac64f584b1d40c02238aeefdaedbe57b Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Mon, 20 May 2024 13:14:33 +0200 Subject: [PATCH] fix: fixed screensharing persistence and track issue (#681) * fixed screensharing persistence and track issue * changes keys for rebuilds --- .../src/call_participants/call_participants.dart | 14 ++------------ .../regular_call_participants_content.dart | 4 +--- .../screen_share_call_participants_content.dart | 6 ++---- .../lib/src/renderer/video_renderer.dart | 2 +- 4 files changed, 6 insertions(+), 20 deletions(-) diff --git a/packages/stream_video_flutter/lib/src/call_participants/call_participants.dart b/packages/stream_video_flutter/lib/src/call_participants/call_participants.dart index 10210ee3e..31810fe7c 100644 --- a/packages/stream_video_flutter/lib/src/call_participants/call_participants.dart +++ b/packages/stream_video_flutter/lib/src/call_participants/call_participants.dart @@ -132,18 +132,8 @@ class _StreamCallParticipantsState extends State { final screenShareTrack = it.screenShareTrack; final isScreenShareEnabled = it.isScreenShareEnabled; - // If the screen share track is local, we don't have to subscribe to - // anything and we can directly use the mute state. - if (screenShareTrack is! RemoteTrackState) return isScreenShareEnabled; - - // If the screen share track is remote and already subscribed and - // received, we can directly use the mute state. - if (screenShareTrack.subscribed && screenShareTrack.received) { - return isScreenShareEnabled; - } - - // If it's not yet subscribed, we have to show it in order for it to - // start the subscription process. + if (screenShareTrack == null || !isScreenShareEnabled) return false; + return true; }, ); diff --git a/packages/stream_video_flutter/lib/src/call_participants/regular_call_participants_content.dart b/packages/stream_video_flutter/lib/src/call_participants/regular_call_participants_content.dart index 5f6d4197e..ca19b2d72 100644 --- a/packages/stream_video_flutter/lib/src/call_participants/regular_call_participants_content.dart +++ b/packages/stream_video_flutter/lib/src/call_participants/regular_call_participants_content.dart @@ -43,9 +43,7 @@ class RegularCallParticipantsContent extends StatelessWidget { CallParticipantState participant, ) { return StreamCallParticipant( - // We use the sessionId as the key to avoid rebuilding the widget - // when the participant changes. - key: ValueKey(participant.sessionId), + key: ValueKey(participant.userId), call: call, participant: participant, ); diff --git a/packages/stream_video_flutter/lib/src/call_participants/screen_share_call_participants_content.dart b/packages/stream_video_flutter/lib/src/call_participants/screen_share_call_participants_content.dart index 2b3f9995b..a88ce469f 100644 --- a/packages/stream_video_flutter/lib/src/call_participants/screen_share_call_participants_content.dart +++ b/packages/stream_video_flutter/lib/src/call_participants/screen_share_call_participants_content.dart @@ -38,9 +38,7 @@ class ScreenShareCallParticipantsContent extends StatelessWidget { CallParticipantState participant, ) { return StreamCallParticipant( - // We use the sessionId as the key to avoid rebuilding the widget - // when the participant changes. - key: ValueKey(participant.sessionId), + key: ValueKey(participant.userId), call: call, participant: participant, ); @@ -67,7 +65,7 @@ class ScreenShareCallParticipantsContent extends StatelessWidget { return Stack( children: [ ScreenShareContent( - key: ValueKey('${participant.sessionId} - screenShareContent'), + key: ValueKey('${participant.userId} - screenShareContent'), call: call, participant: participant, ), diff --git a/packages/stream_video_flutter/lib/src/renderer/video_renderer.dart b/packages/stream_video_flutter/lib/src/renderer/video_renderer.dart index b825492bf..c023f16b7 100644 --- a/packages/stream_video_flutter/lib/src/renderer/video_renderer.dart +++ b/packages/stream_video_flutter/lib/src/renderer/video_renderer.dart @@ -58,7 +58,7 @@ class StreamVideoRenderer extends StatelessWidget { } return VisibilityDetector( - key: Key('${participant.sessionId}${trackState?.muted}'), + key: Key('${participant.userId}${participant.sessionId}$videoTrackType${trackState?.muted}'), onVisibilityChanged: _onVisibilityChanged, child: child, );