-
Notifications
You must be signed in to change notification settings - Fork 53
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
VBLOCKS-1111 | Fix sound definitions #153
Changes from 3 commits
1d4b7aa
5b7c76d
312dff9
da15d6d
1eb9189
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -354,15 +354,6 @@ class Device extends EventEmitter { | |
*/ | ||
private _edge: string | null = null; | ||
|
||
/** | ||
* Whether each sound is enabled. | ||
*/ | ||
private _enabledSounds: Record<Device.ToggleableSound, boolean> = { | ||
[Device.SoundName.Disconnect]: true, | ||
[Device.SoundName.Incoming]: true, | ||
[Device.SoundName.Outgoing]: true, | ||
}; | ||
|
||
/** | ||
* The name of the home region the {@link Device} is connected to. | ||
*/ | ||
|
@@ -978,7 +969,7 @@ class Device extends EventEmitter { | |
maxAverageBitrate: this._options.maxAverageBitrate, | ||
preflight: this._options.preflight, | ||
rtcConstraints: this._options.rtcConstraints, | ||
shouldPlayDisconnect: () => this._enabledSounds.disconnect, | ||
shouldPlayDisconnect: () => this.audio?.disconnect(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When would There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's initial value is |
||
twimlParams, | ||
voiceEventSidGenerator: this._options.voiceEventSidGenerator, | ||
}, options); | ||
|
@@ -1003,7 +994,7 @@ class Device extends EventEmitter { | |
this._audio._maybeStartPollingVolume(); | ||
} | ||
|
||
if (call.direction === Call.CallDirection.Outgoing && this._enabledSounds.outgoing) { | ||
if (call.direction === Call.CallDirection.Outgoing && this.audio?.outgoing()) { | ||
this._soundcache.get(Device.SoundName.Outgoing).play(); | ||
} | ||
|
||
|
@@ -1213,7 +1204,7 @@ class Device extends EventEmitter { | |
this._publishNetworkChange(); | ||
}); | ||
|
||
const play = (this._enabledSounds.incoming && !wasBusy) | ||
const play = (this.audio?.incoming() && !wasBusy) | ||
? () => this._soundcache.get(Device.SoundName.Incoming).play() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems like this kind of logic could be placed in the |
||
: () => Promise.resolve(); | ||
|
||
|
@@ -1320,10 +1311,7 @@ class Device extends EventEmitter { | |
this._updateSinkIds, | ||
this._updateInputStream, | ||
getUserMedia, | ||
{ | ||
audioContext: Device.audioContext, | ||
enabledSounds: this._enabledSounds, | ||
}, | ||
{ audioContext: Device.audioContext }, | ||
); | ||
|
||
this._audio.on('deviceChange', (lostActiveDevices: MediaDeviceInfo[]) => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ | |
"url": "[email protected]:twilio/twilio-voice.js.git" | ||
}, | ||
"scripts": { | ||
"build": "npm-run-all clean build:constants build:errors docs:ts build:es5 build:ts build:dist build:dist-min", | ||
"build": "npm-run-all clean build:constants build:errors docs:ts build:es5 build:ts build:dist build:dist-min test:typecheck", | ||
"build:errors": "node ./scripts/errors.js", | ||
"build:es5": "rimraf ./es5 && babel lib -d es5", | ||
"build:dev": "ENV=dev npm run build", | ||
|
@@ -55,6 +55,7 @@ | |
"test:integration": "karma start $PWD/karma.conf.ts", | ||
"test:network": "node ./scripts/karma.js $PWD/karma.network.conf.ts", | ||
"test:selenium": "mocha tests/browser/index.js", | ||
"test:typecheck": "./node_modules/typescript/bin/tsc tests/typecheck/index.ts --noEmit", | ||
"test:unit": "nyc mocha -r ts-node/register ./tests/index.ts", | ||
"test:webpack": "cd ./tests/webpack && npm install && npm test" | ||
}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we pass
undefined
it seems like these functions just report the enable status of the sound, is that correct? Should we put that behavior in the docstring?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that's correct. If you looks at the generated API doc, the return value kind of explains that right? That is, it's always returning the enable status of the sound whether you pass a boolean or undefined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My confusion is that I wasn't sure if passing
undefined
would be inferred asfalse
since it's a falsy value, or if it would make it a no-op.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It won't be. See
_maybeEnableSound
implementation in this file. I also added tests for this. Please see the tests.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah did you mean something like
disconnect(undefined)
instead ofdisconnect()
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's clear when reading the implementation but not when reading only the docstring, is what I'm trying to say. Applies to either implicit or explicit
undefined
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok gotcha. Can you provide a suggestion on the docstring? What would make it clear?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this sound?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is too verbose.
Re: @param doEnable. Typedoc already generates explanation that this is an optional boolean value. I don't think mentioning it again in the docstring is good.
Re: @returns. Typedoc also mentions that the return value is boolean. No need to mention again.
I tweaked it a bit. Please see latest.