|
@@ -11,7 +11,10 @@ import { MEDIA_TYPE, type MediaType } from '../base/media/constants';
|
11
|
11
|
import {
|
12
|
12
|
getDominantSpeakerParticipant,
|
13
|
13
|
isLocalParticipantModerator,
|
14
|
|
- isParticipantModerator
|
|
14
|
+ isParticipantModerator,
|
|
15
|
+ getLocalParticipant,
|
|
16
|
+ getRemoteParticipantsSorted,
|
|
17
|
+ getRaiseHandsQueue
|
15
|
18
|
} from '../base/participants/functions';
|
16
|
19
|
import { toState } from '../base/redux';
|
17
|
20
|
|
|
@@ -188,3 +191,57 @@ export const shouldRenderInviteButton = (state: Object) => {
|
188
|
191
|
|
189
|
192
|
return flagEnabled && !disableInviteFunctions;
|
190
|
193
|
};
|
|
194
|
+
|
|
195
|
+/**
|
|
196
|
+ * Selector for retrieving ids of participants in the order that they are displayed in the filmstrip (with the
|
|
197
|
+ * exception of participants with raised hand). The participants are reordered as follows.
|
|
198
|
+ * 1. Dominant speaker.
|
|
199
|
+ * 2. Local participant.
|
|
200
|
+ * 3. Participants with raised hand.
|
|
201
|
+ * 4. Participants with screenshare sorted alphabetically by their display name.
|
|
202
|
+ * 5. Shared video participants.
|
|
203
|
+ * 6. Recent speakers sorted alphabetically by their display name.
|
|
204
|
+ * 7. Rest of the participants sorted alphabetically by their display name.
|
|
205
|
+ *
|
|
206
|
+ * @param {(Function|Object)} stateful - The (whole) redux state, or redux's
|
|
207
|
+ * {@code getState} function to be used to retrieve the state features/base/participants.
|
|
208
|
+ * @returns {Array<string>}
|
|
209
|
+ */
|
|
210
|
+export function getSortedParticipantIds(stateful: Object | Function): Array<string> {
|
|
211
|
+ const { id } = getLocalParticipant(stateful);
|
|
212
|
+ const remoteParticipants = getRemoteParticipantsSorted(stateful);
|
|
213
|
+ const reorderedParticipants = new Set(remoteParticipants);
|
|
214
|
+ const raisedHandParticipants = getRaiseHandsQueue(stateful);
|
|
215
|
+ const remoteRaisedHandParticipants = new Set(raisedHandParticipants || []);
|
|
216
|
+ const dominantSpeaker = getDominantSpeakerParticipant(stateful);
|
|
217
|
+
|
|
218
|
+ for (const participant of remoteRaisedHandParticipants.keys()) {
|
|
219
|
+ // Avoid duplicates.
|
|
220
|
+ if (reorderedParticipants.has(participant)) {
|
|
221
|
+ reorderedParticipants.delete(participant);
|
|
222
|
+ } else {
|
|
223
|
+ remoteRaisedHandParticipants.delete(participant);
|
|
224
|
+ }
|
|
225
|
+ }
|
|
226
|
+
|
|
227
|
+ // Remove self.
|
|
228
|
+ remoteRaisedHandParticipants.delete(id);
|
|
229
|
+
|
|
230
|
+ const dominant = [];
|
|
231
|
+
|
|
232
|
+ // Remove dominant speaker.
|
|
233
|
+ if (dominantSpeaker && dominantSpeaker.id !== id) {
|
|
234
|
+ remoteRaisedHandParticipants.delete(dominantSpeaker.id);
|
|
235
|
+ reorderedParticipants.delete(dominantSpeaker.id);
|
|
236
|
+ dominant.push(dominantSpeaker.id);
|
|
237
|
+ }
|
|
238
|
+
|
|
239
|
+ // Move self and participants with raised hand to the top of the list.
|
|
240
|
+ return [
|
|
241
|
+ ...dominant,
|
|
242
|
+ id,
|
|
243
|
+ ...Array.from(remoteRaisedHandParticipants.keys()),
|
|
244
|
+ ...Array.from(reorderedParticipants.keys())
|
|
245
|
+ ];
|
|
246
|
+}
|
|
247
|
+
|