From ff04987557219ded6bfcec4aea5970dbb579abaa Mon Sep 17 00:00:00 2001 From: Matvei Andrienko Date: Wed, 11 Dec 2024 17:17:42 +0100 Subject: [PATCH] additional guard against dropping not ringing call --- packages/client/src/Call.ts | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/packages/client/src/Call.ts b/packages/client/src/Call.ts index d93ddb1a6..73e67715e 100644 --- a/packages/client/src/Call.ts +++ b/packages/client/src/Call.ts @@ -342,6 +342,7 @@ export class Call { ); this.leaveCallHooks.add( + // cancel auto-drop when call is createSubscription(this.state.session$, (session) => { if (!this.ringing) return; @@ -357,21 +358,6 @@ export class Call { }), ); - this.leaveCallHooks.add( - // watch for auto drop cancellation - createSubscription(this.state.callingState$, (callingState) => { - if (!this.ringing) return; - if ( - callingState === CallingState.JOINED || - callingState === CallingState.JOINING || - callingState === CallingState.LEFT - ) { - clearTimeout(this.dropTimeout); - this.dropTimeout = undefined; - } - }), - ); - this.leaveCallHooks.add( // "ringing" mode effects and event handlers createSubscription(this.ringingSubject, (isRinging) => { @@ -2031,6 +2017,9 @@ export class Call { if (timeoutInMs <= 0) return; this.dropTimeout = setTimeout(() => { + // the call might have stopped ringing by this point, + // e.g. it was already accepted and joined + if (this.state.callingState !== CallingState.RINGING) return; this.leave({ reject: true, reason: 'timeout' }).catch((err) => { this.logger('error', 'Failed to drop call', err); });