Skip to content

Commit

Permalink
GH95 | error is not returned when mic access is blocked (twilio#144)
Browse files Browse the repository at this point in the history
* GH95 | error is not returned when mic access is blocked

* PR Review
  • Loading branch information
charliesantos committed Feb 22, 2023
1 parent 05abfa4 commit 7fac702
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
2.3.2 (In Progress)
===================

Bug Fixes
---------

- Fixed an [issue](https://github.com/twilio/twilio-voice.js/issues/95) where a Twilio error is not returned when microphone access is blocked. Thank you @SiimMardus and @ostap0207 for your [contribution](https://github.com/twilio/twilio-voice.js/pull/143).

2.3.1 (February 3, 2023)
===================

Expand Down
4 changes: 4 additions & 0 deletions lib/twilio/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,10 @@ class Device extends EventEmitter {
}, options);

const maybeUnsetPreferredUri = () => {
if (!this._stream) {
this._log.warn('UnsetPreferredUri called without a stream');
return;
}
if (this._activeCall === null && this._calls.length === 0) {
this._stream.updatePreferredURI(null);
}
Expand Down
10 changes: 10 additions & 0 deletions tests/unit/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,16 @@ describe('Device', function() {
device.calls[0].emit('error');
sinon.assert.calledOnce(spyIncomingSound.stop);
});

it('should not unset the preferred uri if stream is null', () => {
const spy: any = device['_stream'].updatePreferredURI =
sinon.spy(device['_stream'].updatePreferredURI);

device['_stream'] = null;
device.calls[0].status = () => CallType.State.Closed;
device.calls[0].emit('error');
sinon.assert.notCalled(spy);
});
});

describe('on call.transportClose', () => {
Expand Down

0 comments on commit 7fac702

Please sign in to comment.