@webex/plugin-meetings 3.8.0-next.70 → 3.8.0-next.71

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,11 +24,17 @@ const SelfUtils = {
24
24
  * parses the relevant values for self: muted, guest, moderator, mediaStatus, state, joinedWith, pstnDevices, creator, id
25
25
  * @param {Object} self
26
26
  * @param {String} deviceId
27
+ * @param {Array} participants
27
28
  * @returns {undefined}
28
29
  */
29
- parse: (self: any, deviceId: string) => {
30
+ parse: (self: any, deviceId: string, participants: Array<any>) => {
30
31
  if (self) {
31
32
  const joinedWith = self.devices.find((device) => deviceId === device.url);
33
+ const pairedWith =
34
+ joinedWith?.intent?.type === _OBSERVE_ &&
35
+ participants?.find((participant) => participant.url === joinedWith?.intent?.associatedWith)
36
+ ?.devices[0];
37
+
32
38
  const pstnDevices = self.devices.filter((device) => PSTN_DEVICE_TYPE === device.deviceType);
33
39
 
34
40
  return {
@@ -50,6 +56,7 @@ const SelfUtils = {
50
56
  // TODO: give a proper name . With same device as login or different login`
51
57
  // Some times we might have joined with both mobile and web
52
58
  joinedWith,
59
+ pairedWith,
53
60
  pstnDevices,
54
61
  // current media stats is for the current device who has joined
55
62
  currentMediaStatus: SelfUtils.getMediaStatus(joinedWith?.mediaSessions),
@@ -59,7 +66,7 @@ const SelfUtils = {
59
66
  selfUrl: self.url,
60
67
  removed: self.removed,
61
68
  roles: SelfUtils.getRoles(self),
62
- isUserUnadmitted: self.state === _IDLE_ && joinedWith?.intent?.type === _WAIT_,
69
+ isUserUnadmitted: SelfUtils.isLocusUserUnadmitted(self?.state, joinedWith, pairedWith),
63
70
  layout: SelfUtils.getLayout(self),
64
71
  canNotViewTheParticipantList: SelfUtils.canNotViewTheParticipantList(self),
65
72
  isSharingBlocked: SelfUtils.isSharingBlocked(self),
@@ -94,13 +101,13 @@ const SelfUtils = {
94
101
 
95
102
  isSharingBlocked: (self) => !!self?.isSharingBlocked,
96
103
 
97
- getSelves: (oldSelf, newSelf, deviceId) => {
98
- const previous = oldSelf && SelfUtils.parse(oldSelf, deviceId);
99
- const current = newSelf && SelfUtils.parse(newSelf, deviceId);
104
+ getSelves: (oldParsedSelf, newSelf, deviceId, participants: Array<any>) => {
105
+ const previous = oldParsedSelf;
106
+ const current = newSelf && SelfUtils.parse(newSelf, deviceId, participants);
100
107
  const updates: any = {};
101
108
 
102
- updates.isUserUnadmitted = SelfUtils.isUserUnadmitted(previous, current);
103
- updates.isUserAdmitted = SelfUtils.isUserAdmitted(previous, current);
109
+ updates.hasUserEnteredLobby = SelfUtils.hasUserEnteredLobby(previous, current);
110
+ updates.hasUserBeenAdmitted = SelfUtils.hasUserBeenAdmitted(previous, current);
104
111
  updates.isVideoMutedByOthersChanged = SelfUtils.videoMutedByOthersChanged(previous, current);
105
112
  updates.isMutedByOthersChanged = SelfUtils.mutedByOthersChanged(previous, current);
106
113
  updates.localAudioUnmuteRequestedByServer = SelfUtils.localAudioUnmuteRequestedByServer(
@@ -316,37 +323,68 @@ const SelfUtils = {
316
323
  changedSelf.joinedWith.reason === MEETING_END_REASON.MEDIA_RELEASED),
317
324
 
318
325
  /**
319
- * @param {Object} check
320
- * @returns {Boolean}
326
+ * @param {String | undefined} state meeting state
327
+ * @param {any} joinedWith device that user has joined with
328
+ * @param {any} pairedWith device that user is paired with
329
+ * @returns {Boolean | undefined} true if user is in lobby, false if not, undefined if it cannot be determined
321
330
  */
322
- isLocusUserUnadmitted: (check: any) =>
323
- check && check.joinedWith?.intent?.type === _WAIT_ && check.state === _IDLE_,
331
+ isLocusUserUnadmitted: (state?: string, joinedWith?: any, pairedWith?: any) => {
332
+ if (state === undefined) {
333
+ return undefined;
334
+ }
335
+ if (joinedWith?.intent?.type === _OBSERVE_ && pairedWith) {
336
+ // we are paired with a device, so need to check the lobby state for that device
337
+ return pairedWith.intent?.type === _WAIT_ && state === _IDLE_;
338
+ }
339
+
340
+ return joinedWith?.intent?.type === _WAIT_ && state === _IDLE_;
341
+ },
324
342
 
325
343
  /**
326
- * @param {Object} check
344
+ * @param {String | undefined} state meeting state
345
+ * @param {any} joinedWith device that user has joined with
346
+ * @param {any} pairedWith device that user is paired with
327
347
  * @returns {Boolean}
328
348
  */
329
- isLocusUserAdmitted: (check: any) =>
330
- check && check.joinedWith?.intent?.type !== _WAIT_ && check.state === _JOINED_,
349
+ isLocusUserAdmitted: (state?: string, joinedWith?: any, pairedWith?: any) => {
350
+ if (state === undefined) {
351
+ return undefined;
352
+ }
353
+
354
+ if (joinedWith?.intent?.type === _OBSERVE_ && pairedWith) {
355
+ // we are paired with a device, so need to check the lobby state for that device
356
+ return pairedWith.intent?.type !== _WAIT_ && state === _JOINED_;
357
+ }
358
+
359
+ return joinedWith?.intent?.type !== _WAIT_ && state === _JOINED_;
360
+ },
331
361
 
332
362
  /**
333
363
  * @param {Object} oldSelf
334
364
  * @param {Object} changedSelf
335
- * @returns {Boolean}
365
+ * @returns {Boolean} true if user has just been placed in the lobby
336
366
  * @throws {Error} when self is undefined
337
367
  */
338
- isUserUnadmitted: (oldSelf: any, changedSelf: any) => {
368
+ hasUserEnteredLobby: (oldSelf: any, changedSelf: any) => {
339
369
  if (!changedSelf) {
340
370
  throw new ParameterError(
341
371
  'changedSelf must be defined to determine if self is unadmitted as guest.'
342
372
  );
343
373
  }
344
374
 
345
- if (SelfUtils.isLocusUserUnadmitted(oldSelf)) {
346
- return false;
347
- }
375
+ const wasInLobby = SelfUtils.isLocusUserUnadmitted(
376
+ oldSelf?.state,
377
+ oldSelf?.joinedWith,
378
+ oldSelf?.pairedWith
379
+ );
380
+
381
+ const isInLobby = SelfUtils.isLocusUserUnadmitted(
382
+ changedSelf?.state,
383
+ changedSelf?.joinedWith,
384
+ changedSelf?.pairedWith
385
+ );
348
386
 
349
- return SelfUtils.isLocusUserUnadmitted(changedSelf);
387
+ return !wasInLobby && isInLobby;
350
388
  },
351
389
 
352
390
  moderatorChanged: (oldSelf, changedSelf) => {
@@ -391,10 +429,10 @@ const SelfUtils = {
391
429
  /**
392
430
  * @param {Object} oldSelf
393
431
  * @param {Object} changedSelf
394
- * @returns {Boolean}
432
+ * @returns {Boolean} true if the user has just been admitted from lobby into the meeting
395
433
  * @throws {Error} if changed self was undefined
396
434
  */
397
- isUserAdmitted: (oldSelf: object, changedSelf: object) => {
435
+ hasUserBeenAdmitted: (oldSelf: any, changedSelf: any) => {
398
436
  if (!oldSelf) {
399
437
  // if there was no previous locus, it couldn't have been admitted yet
400
438
  return false;
@@ -405,7 +443,19 @@ const SelfUtils = {
405
443
  );
406
444
  }
407
445
 
408
- return SelfUtils.isLocusUserUnadmitted(oldSelf) && SelfUtils.isLocusUserAdmitted(changedSelf);
446
+ const wasInLobby = SelfUtils.isLocusUserUnadmitted(
447
+ oldSelf?.state,
448
+ oldSelf?.joinedWith,
449
+ oldSelf?.pairedWith
450
+ );
451
+
452
+ const isAdmitted = SelfUtils.isLocusUserAdmitted(
453
+ changedSelf?.state,
454
+ changedSelf?.joinedWith,
455
+ changedSelf?.pairedWith
456
+ );
457
+
458
+ return wasInLobby && isAdmitted && isAdmitted !== undefined;
409
459
  },
410
460
 
411
461
  videoMutedByOthersChanged: (oldSelf, changedSelf) => {