Skip to content

Commit

Permalink
fix: call.recording_failed should update the call state (#1452)
Browse files Browse the repository at this point in the history
When the `call.recording_failed` event is emitted, we should update the call
state and notify that the call isn't recorded anymore.
  • Loading branch information
oliverlaz authored Jul 31, 2024
1 parent fec6985 commit 439b7f0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/client/src/store/CallState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,6 @@ export class CallState {
'call.closed_caption': undefined,
'call.deleted': undefined,
'call.permission_request': undefined,
'call.recording_failed': undefined,
'call.recording_ready': undefined,
'call.transcription_ready': undefined,
'call.user_muted': undefined,
Expand Down Expand Up @@ -470,6 +469,8 @@ export class CallState {
this.setCurrentValue(this.recordingSubject, true),
'call.recording_stopped': () =>
this.setCurrentValue(this.recordingSubject, false),
'call.recording_failed': () =>
this.setCurrentValue(this.recordingSubject, false),
'call.rejected': (e) => this.updateFromCallResponse(e.call),
'call.ring': (e) => this.updateFromCallResponse(e.call),
'call.missed': (e) => this.updateFromCallResponse(e.call),
Expand Down
10 changes: 10 additions & 0 deletions packages/client/src/store/__tests__/CallState.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,16 @@ describe('CallState', () => {
expect(state.recording).toBe(false);
});

it('handles call.recording_failed events', () => {
const state = new CallState();
// @ts-expect-error incomplete data
state.updateFromEvent({ type: 'call.recording_started' });
expect(state.recording).toBe(true);
// @ts-expect-error incomplete data
state.updateFromEvent({ type: 'call.recording_failed' });
expect(state.recording).toBe(false);
});

it('handles call.hls_broadcasting_started events', () => {
const state = new CallState();
state.updateFromCallResponse({
Expand Down

0 comments on commit 439b7f0

Please sign in to comment.