Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: leave ringing call if accepted or rejected elsewhere #1654

Merged
merged 2 commits into from
Jan 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions packages/client/src/Call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ import {
SpeakerManager,
} from './devices';
import { getSdkSignature } from './stats/utils';
import { withoutConcurrency } from './helpers/concurrency';
import { hasPending, withoutConcurrency } from './helpers/concurrency';
import { ensureExhausted } from './helpers/ensureExhausted';
import { pushToIfMissing } from './helpers/array';
import {
Expand Down Expand Up @@ -360,7 +360,7 @@ export class Call {
);

this.leaveCallHooks.add(
// cancel auto-drop when call is
// cancel auto-drop when call is accepted or rejected
createSubscription(this.state.session$, (session) => {
if (!this.ringing) return;

Expand All @@ -373,6 +373,21 @@ export class Call {
if (isAcceptedByMe || isRejectedByMe) {
this.cancelAutoDrop();
}

const isAcceptedElsewhere =
isAcceptedByMe && this.state.callingState === CallingState.RINGING;

if (
(isAcceptedElsewhere || isRejectedByMe) &&
!hasPending(this.joinLeaveConcurrencyTag)
) {
this.leave().catch(() => {
this.logger(
'error',
'Could not leave a call that was accepted or rejected elsewhere',
);
});
}
}),
);

Expand Down
Loading