@stream-io/video-client 1.28.0 → 1.28.1

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.
@@ -125,6 +125,7 @@ export declare class Call {
125
125
  */
126
126
  setup: () => Promise<void>;
127
127
  private registerEffects;
128
+ private handleRingingCall;
128
129
  private handleOwnCapabilitiesUpdated;
129
130
  /**
130
131
  * You can subscribe to WebSocket events provided by the API. To remove a subscription, call the `off` method.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stream-io/video-client",
3
- "version": "1.28.0",
3
+ "version": "1.28.1",
4
4
  "main": "dist/index.cjs.js",
5
5
  "module": "dist/index.es.js",
6
6
  "browser": "dist/index.browser.es.js",
package/src/Call.ts CHANGED
@@ -399,6 +399,21 @@ export class Call {
399
399
  }),
400
400
  );
401
401
 
402
+ if (this.ringing) {
403
+ // if the call is ringing, we need to register the ringing call effects
404
+ this.handleRingingCall();
405
+ } else {
406
+ // if the call is not ringing, we need to register the ringing call subscriptions
407
+ // to handle the case when the call gets ringing flag after creation event
408
+ this.leaveCallHooks.add(
409
+ // "ringing" mode effects and event handlers
410
+ createSubscription(this.ringingSubject, (isRinging) => {
411
+ if (!isRinging) return;
412
+ this.handleRingingCall();
413
+ }),
414
+ );
415
+ }
416
+
402
417
  this.leaveCallHooks.add(
403
418
  // cancel auto-drop when call is accepted or rejected
404
419
  createSubscription(this.state.session$, (session) => {
@@ -430,50 +445,46 @@ export class Call {
430
445
  }
431
446
  }),
432
447
  );
448
+ };
433
449
 
434
- this.leaveCallHooks.add(
435
- // "ringing" mode effects and event handlers
436
- createSubscription(this.ringingSubject, (isRinging) => {
437
- if (!isRinging) return;
438
- const callSession = this.state.session;
439
- const receiver_id = this.clientStore.connectedUser?.id;
440
- const ended_at = callSession?.ended_at;
441
- const created_by_id = this.state.createdBy?.id;
442
- const rejected_by = callSession?.rejected_by;
443
- const accepted_by = callSession?.accepted_by;
444
- let leaveCallIdle = false;
445
- if (ended_at) {
446
- // call was ended before it was accepted or rejected so we should leave it to idle
447
- leaveCallIdle = true;
448
- } else if (created_by_id && rejected_by) {
449
- if (rejected_by[created_by_id]) {
450
- // call was cancelled by the caller
451
- leaveCallIdle = true;
452
- }
453
- } else if (receiver_id && rejected_by) {
454
- if (rejected_by[receiver_id]) {
455
- // call was rejected by the receiver in some other device
456
- leaveCallIdle = true;
457
- }
458
- } else if (receiver_id && accepted_by) {
459
- if (accepted_by[receiver_id]) {
460
- // call was accepted by the receiver in some other device
461
- leaveCallIdle = true;
462
- }
463
- }
464
- if (leaveCallIdle) {
465
- if (this.state.callingState !== CallingState.IDLE) {
466
- this.state.setCallingState(CallingState.IDLE);
467
- }
468
- } else {
469
- if (this.state.callingState === CallingState.IDLE) {
470
- this.state.setCallingState(CallingState.RINGING);
471
- }
472
- this.scheduleAutoDrop();
473
- this.leaveCallHooks.add(registerRingingCallEventHandlers(this));
474
- }
475
- }),
476
- );
450
+ private handleRingingCall = () => {
451
+ const callSession = this.state.session;
452
+ const receiver_id = this.clientStore.connectedUser?.id;
453
+ const ended_at = callSession?.ended_at;
454
+ const created_by_id = this.state.createdBy?.id;
455
+ const rejected_by = callSession?.rejected_by;
456
+ const accepted_by = callSession?.accepted_by;
457
+ let leaveCallIdle = false;
458
+ if (ended_at) {
459
+ // call was ended before it was accepted or rejected so we should leave it to idle
460
+ leaveCallIdle = true;
461
+ } else if (created_by_id && rejected_by) {
462
+ if (rejected_by[created_by_id]) {
463
+ // call was cancelled by the caller
464
+ leaveCallIdle = true;
465
+ }
466
+ } else if (receiver_id && rejected_by) {
467
+ if (rejected_by[receiver_id]) {
468
+ // call was rejected by the receiver in some other device
469
+ leaveCallIdle = true;
470
+ }
471
+ } else if (receiver_id && accepted_by) {
472
+ if (accepted_by[receiver_id]) {
473
+ // call was accepted by the receiver in some other device
474
+ leaveCallIdle = true;
475
+ }
476
+ }
477
+ if (leaveCallIdle) {
478
+ if (this.state.callingState !== CallingState.IDLE) {
479
+ this.state.setCallingState(CallingState.IDLE);
480
+ }
481
+ } else {
482
+ if (this.state.callingState === CallingState.IDLE) {
483
+ this.state.setCallingState(CallingState.RINGING);
484
+ }
485
+ this.scheduleAutoDrop();
486
+ this.leaveCallHooks.add(registerRingingCallEventHandlers(this));
487
+ }
477
488
  };
478
489
 
479
490
  private handleOwnCapabilitiesUpdated = async (
@@ -66,11 +66,6 @@ export const registerEventHandlers = (call: Call, dispatcher: Dispatcher) => {
66
66
  handleRemoteSoftMute(call),
67
67
  ];
68
68
 
69
- if (call.ringing) {
70
- // these events are only relevant when the call is ringing
71
- eventHandlers.push(registerRingingCallEventHandlers(call));
72
- }
73
-
74
69
  return () => {
75
70
  eventHandlers.forEach((unsubscribe) => unsubscribe());
76
71
  };