@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.
- package/CHANGELOG.md +6 -0
- package/dist/index.browser.es.js +54 -47
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +54 -47
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +54 -47
- package/dist/index.es.js.map +1 -1
- package/dist/src/Call.d.ts +1 -0
- package/package.json +1 -1
- package/src/Call.ts +54 -43
- package/src/events/callEventHandlers.ts +0 -5
package/dist/src/Call.d.ts
CHANGED
|
@@ -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
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
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
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
|
};
|