Skip to content

Commit

Permalink
fix: do not use ended_at from call state to check ringing validity (#…
Browse files Browse the repository at this point in the history
…1466)

**Behaviour**: 
we should not schedule timeout based rejects if the call had already
ended, as BE will respond with 400

**Background**:
`callState.ended_at` represents the last time the call was ended
`callSession.ended_at` represents if the current call session's ended
time

**Fix:**
we should not schedule timeout based rejects if `callSession.ended_at`
is present and not based on `callState.ended_at`
  • Loading branch information
santhoshvai authored Aug 23, 2024
1 parent dd0ca37 commit 4af7f00
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/client/src/Call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,12 +437,12 @@ export class Call {
if (!isRinging) return;
const callSession = this.state.session;
const receiver_id = this.clientStore.connectedUser?.id;
const endedAt = this.state.endedAt;
const ended_at = callSession?.ended_at;
const created_by_id = this.state.createdBy?.id;
const rejected_by = callSession?.rejected_by;
const accepted_by = callSession?.accepted_by;
let leaveCallIdle = false;
if (endedAt) {
if (ended_at) {
// call was ended before it was accepted or rejected so we should leave it to idle
leaveCallIdle = true;
} else if (created_by_id && rejected_by) {
Expand All @@ -466,10 +466,10 @@ export class Call {
this.state.setCallingState(CallingState.IDLE);
}
} else {
this.scheduleAutoDrop();
if (this.state.callingState === CallingState.IDLE) {
this.state.setCallingState(CallingState.RINGING);
}
this.scheduleAutoDrop();
this.leaveCallHooks.add(registerRingingCallEventHandlers(this));
}
}),
Expand Down

0 comments on commit 4af7f00

Please sign in to comment.