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

[VBLOCKS-3256] Feat: listen for navigator permissions changes #283

Merged
merged 8 commits into from
Aug 13, 2024

Conversation

kpchoy
Copy link
Collaborator

@kpchoy kpchoy commented Aug 1, 2024

Contributing to Twilio

All third party contributors acknowledge that any contributions they provide will be made under the same open source license that the open source project is provided under.

  • I acknowledge that all my contributions will be made under the project's license.

Pull Request Details

JIRA link(s):

Description

Reference issue: #228

  • allow user to instantiate the Twilio Device after the permissions are set
  • listen to microphone permission changes

Burndown

Tested:

Before review

  • Updated CHANGELOG.md if necessary
  • Added unit tests if necessary
  • Updated affected documentation
  • Verified locally with npm test
  • Manually sanity tested running locally
  • Ready for review

Before merge

  • Got one or more +1s
  • Squashed erroneous commits if necessary
  • Re-tested if necessary

@kpchoy kpchoy force-pushed the VBLOCKS-3256/navigator-permissions branch from 437cad3 to aee840f Compare August 1, 2024 23:48
@kpchoy kpchoy force-pushed the VBLOCKS-3256/navigator-permissions branch from aee840f to 698148f Compare August 2, 2024 18:37
Copy link
Collaborator

@charliesantos charliesantos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments. Also

  • add changelog
  • update from master

lib/twilio/audiohelper.ts Show resolved Hide resolved
lib/twilio/audiohelper.ts Outdated Show resolved Hide resolved
@@ -275,6 +275,16 @@ class AudioHelper extends EventEmitter {
if (isEnumerationSupported) {
this._initializeEnumeration();
}

navigator.permissions.query({ name: 'microphone' as PermissionName }).then((microphonePermissionStatus) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to cast 'microphone' as PermissionName here? I don't believe so from my testing unless I'm missing something.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My VScode is giving my a type error, but it looks like it compiles fine without the typecast 👍

Comment on lines 170 to 171
navigator.permissions.query = () => Promise.resolve(microphonePermissionStatus);
audio = new AudioHelper(onActiveOutputsChanged, onActiveInputChanged, {});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like this test might not going through SDK codepaths, unless my understanding is incorrect. If you remove these two lines, I don't think much changes? It seems like you're creating the microphonePermissionStatus object above and then lines 172~173 test that code path?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your point :( . I am having a hard time testing this feature correctly. Any suggestions?
cc: @charliesantos

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's get the implementation approved then I'll review the tests 😄
That way, we don't have to keep updating the tests while we review the PR.

@kpchoy kpchoy requested review from mhuynh5757 and charliesantos and removed request for mhuynh5757 and charliesantos August 2, 2024 22:49
CHANGELOG.md Outdated Show resolved Hide resolved
lib/twilio/audiohelper.ts Outdated Show resolved Hide resolved
lib/twilio/audiohelper.ts Outdated Show resolved Hide resolved
Comment on lines 170 to 171
navigator.permissions.query = () => Promise.resolve(microphonePermissionStatus);
audio = new AudioHelper(onActiveOutputsChanged, onActiveInputChanged, {});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's get the implementation approved then I'll review the tests 😄
That way, we don't have to keep updating the tests while we review the PR.

@kpchoy kpchoy requested a review from charliesantos August 12, 2024 17:51
tests/index.ts Outdated Show resolved Hide resolved
tests/audiohelper.js Outdated Show resolved Hide resolved
tests/audiohelper.js Outdated Show resolved Hide resolved
Copy link
Collaborator

@charliesantos charliesantos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kpchoy +1 on the implementation. Please check the tests and +1 if you approve.

Copy link
Collaborator Author

@kpchoy kpchoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manual test lgtm +1

@kpchoy kpchoy requested a review from mhuynh5757 August 13, 2024 18:48
@kpchoy kpchoy merged commit 5cbdefb into master Aug 13, 2024
7 checks passed
@kpchoy kpchoy deleted the VBLOCKS-3256/navigator-permissions branch August 13, 2024 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants