From 97bc41f644ad1dc142bd81d9eafbce431e6f4c75 Mon Sep 17 00:00:00 2001 From: Jaya Allamsetty <54324652+jallamsetty1@users.noreply.github.com> Date: Tue, 16 Aug 2022 13:20:29 -0400 Subject: [PATCH] fix(filmstrip) Push dominant speaker to the top of the active speaker list. The active speaker list in redux is alpha sorted, we need to ensure dominant speaker is at the top otherwise it can get truncated based on the available number of visible slots in the filmstrip. --- react/features/base/participants/functions.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/react/features/base/participants/functions.ts b/react/features/base/participants/functions.ts index ce9ceef09..b7365b74a 100644 --- a/react/features/base/participants/functions.ts +++ b/react/features/base/participants/functions.ts @@ -71,7 +71,7 @@ export function getActiveSpeakersToBeDisplayed(stateful: IStore | Function) { speakersList } = state['features/base/participants']; const { visibleRemoteParticipants } = state['features/filmstrip']; - const activeSpeakers = new Map(speakersList); + let activeSpeakers = new Map(speakersList); // Do not re-sort the active speakers if dominant speaker is currently visible. if (dominantSpeaker && visibleRemoteParticipants.has(dominantSpeaker)) { @@ -79,6 +79,19 @@ export function getActiveSpeakersToBeDisplayed(stateful: IStore | Function) { } let availableSlotsForActiveSpeakers = visibleRemoteParticipants.size; + if (activeSpeakers.has(dominantSpeaker)) { + activeSpeakers.delete(dominantSpeaker); + } + + // Add dominant speaker to the beginning of the list (not including self) since the active speaker list is always + // alphabetically sorted. + if (dominantSpeaker && dominantSpeaker !== getLocalParticipant(state).id) { + const updatedSpeakers = Array.from(activeSpeakers); + + updatedSpeakers.splice(0, 0, [ dominantSpeaker, getParticipantById(state, dominantSpeaker)?.name ]); + activeSpeakers = new Map(updatedSpeakers); + } + // Remove screenshares from the count. if (getMultipleVideoSupportFeatureFlag(state)) { if (sortedRemoteVirtualScreenshareParticipants) {