From b91add8b610ba04258675c2ada0f76cb8b317434 Mon Sep 17 00:00:00 2001 From: Hristo Terezov Date: Mon, 8 Jan 2024 16:19:10 -0600 Subject: [PATCH] fix(remote-sources): update only when neccessary Updates the remoteVideoSources set only when neccessary when participant is leaving . This fixes an endless recursion when visitor is promoted or left and there is a screen sharing. --- react/features/base/participants/reducer.ts | 37 +++++++++++---------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/react/features/base/participants/reducer.ts b/react/features/base/participants/reducer.ts index 92d8fce39909..98871fc84811 100644 --- a/react/features/base/participants/reducer.ts +++ b/react/features/base/participants/reducer.ts @@ -374,23 +374,6 @@ ReducerRegistry.register('features/base/participants', let oldParticipant = remote.get(id); let isLocalScreenShare = false; - if (oldParticipant?.sources?.size) { - const videoSources: Map | undefined = oldParticipant.sources.get(MEDIA_TYPE.VIDEO); - const newRemoteVideoSources = new Set(state.remoteVideoSources); - - if (videoSources?.size) { - for (const source of videoSources.keys()) { - newRemoteVideoSources.delete(source); - } - } - state.remoteVideoSources = newRemoteVideoSources; - } else if (oldParticipant?.fakeParticipant === FakeParticipant.RemoteScreenShare) { - const newRemoteVideoSources = new Set(state.remoteVideoSources); - - newRemoteVideoSources.delete(id); - state.remoteVideoSources = newRemoteVideoSources; - } - if (oldParticipant && oldParticipant.conference === conference) { remote.delete(id); } else if (local?.id === id) { @@ -405,6 +388,26 @@ ReducerRegistry.register('features/base/participants', return state; } + if (oldParticipant?.sources?.size) { + const videoSources: Map | undefined = oldParticipant.sources.get(MEDIA_TYPE.VIDEO); + + if (videoSources?.size) { + const newRemoteVideoSources = new Set(state.remoteVideoSources); + + for (const source of videoSources.keys()) { + newRemoteVideoSources.delete(source); + } + + state.remoteVideoSources = newRemoteVideoSources; + } + } else if (oldParticipant?.fakeParticipant === FakeParticipant.RemoteScreenShare) { + const newRemoteVideoSources = new Set(state.remoteVideoSources); + + if (newRemoteVideoSources.delete(id)) { + state.remoteVideoSources = newRemoteVideoSources; + } + } + state.sortedRemoteParticipants.delete(id); state.raisedHandsQueue = state.raisedHandsQueue.filter(pid => pid.id !== id);