|
@@ -1,3 +1,9 @@
|
|
1
|
+/* global interfaceConfig */
|
|
2
|
+
|
|
3
|
+import throttle from 'lodash/throttle';
|
|
4
|
+
|
|
5
|
+import { Notification, showNotification } from '../../notifications';
|
|
6
|
+
|
1
|
7
|
import {
|
2
|
8
|
DOMINANT_SPEAKER_CHANGED,
|
3
|
9
|
KICK_PARTICIPANT,
|
|
@@ -318,3 +324,79 @@ export function pinParticipant(id) {
|
318
|
324
|
}
|
319
|
325
|
};
|
320
|
326
|
}
|
|
327
|
+
|
|
328
|
+/**
|
|
329
|
+ * An array of names of participants that have joined the conference. The array
|
|
330
|
+ * is replaced with an empty array as notifications are displayed.
|
|
331
|
+ *
|
|
332
|
+ * @private
|
|
333
|
+ * @type {string[]}
|
|
334
|
+ */
|
|
335
|
+let joinedParticipantsNames = [];
|
|
336
|
+
|
|
337
|
+/**
|
|
338
|
+ * A throttled internal function that takes the internal list of participant
|
|
339
|
+ * names, {@code joinedParticipantsNames}, and triggers the display of a
|
|
340
|
+ * notification informing of their joining.
|
|
341
|
+ *
|
|
342
|
+ * @private
|
|
343
|
+ * @type {Function}
|
|
344
|
+ */
|
|
345
|
+const _throttledNotifyParticipantConnected = throttle(dispatch => {
|
|
346
|
+ const joinedParticipantsCount = joinedParticipantsNames.length;
|
|
347
|
+
|
|
348
|
+ let notificationProps;
|
|
349
|
+
|
|
350
|
+ if (joinedParticipantsCount >= 3) {
|
|
351
|
+ notificationProps = {
|
|
352
|
+ titleArguments: {
|
|
353
|
+ name: joinedParticipantsNames[0],
|
|
354
|
+ count: joinedParticipantsCount - 1
|
|
355
|
+ },
|
|
356
|
+ titleKey: 'notify.connectedThreePlusMembers'
|
|
357
|
+ };
|
|
358
|
+ } else if (joinedParticipantsCount === 2) {
|
|
359
|
+ notificationProps = {
|
|
360
|
+ titleArguments: {
|
|
361
|
+ first: joinedParticipantsNames[0],
|
|
362
|
+ second: joinedParticipantsNames[1]
|
|
363
|
+ },
|
|
364
|
+ titleKey: 'notify.connectedTwoMembers'
|
|
365
|
+ };
|
|
366
|
+ } else if (joinedParticipantsCount) {
|
|
367
|
+ notificationProps = {
|
|
368
|
+ titleArguments: {
|
|
369
|
+ name: joinedParticipantsNames[0]
|
|
370
|
+ },
|
|
371
|
+ titleKey: 'notify.connectedOneMember'
|
|
372
|
+ };
|
|
373
|
+ }
|
|
374
|
+
|
|
375
|
+ if (notificationProps) {
|
|
376
|
+ dispatch(
|
|
377
|
+ showNotification(
|
|
378
|
+ Notification,
|
|
379
|
+ notificationProps,
|
|
380
|
+ 2500));
|
|
381
|
+ }
|
|
382
|
+
|
|
383
|
+ joinedParticipantsNames = [];
|
|
384
|
+
|
|
385
|
+}, 500, { leading: false });
|
|
386
|
+
|
|
387
|
+/**
|
|
388
|
+ * Queues the display of a notification of a participant having connected to
|
|
389
|
+ * the meeting. The notifications are batched so that quick consecutive
|
|
390
|
+ * connection events are shown in one notification.
|
|
391
|
+ *
|
|
392
|
+ * @param {string} displayName - The name of the participant that connected.
|
|
393
|
+ * @returns {Function}
|
|
394
|
+ */
|
|
395
|
+export function showParticipantJoinedNotification(displayName) {
|
|
396
|
+ joinedParticipantsNames.push(
|
|
397
|
+ displayName || interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME);
|
|
398
|
+
|
|
399
|
+ return dispatch => {
|
|
400
|
+ _throttledNotifyParticipantConnected(dispatch);
|
|
401
|
+ };
|
|
402
|
+}
|