Skip to content

Commit

Permalink
fix: fixed screensharing persistence and track issue (#681)
Browse files Browse the repository at this point in the history
* fixed screensharing persistence and track issue

* changes keys for rebuilds
  • Loading branch information
deven98 committed May 20, 2024
1 parent 4230b20 commit 9ffac3b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,18 +132,8 @@ class _StreamCallParticipantsState extends State<StreamCallParticipants> {
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;
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand All @@ -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,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand Down

0 comments on commit 9ffac3b

Please sign in to comment.