Skip to content

Commit

Permalink
ref(client) simplify code in av-utils
Browse files Browse the repository at this point in the history
- enumerateDevices already checks for permissions
- inline hasPermissions
  • Loading branch information
saghul committed May 31, 2024
1 parent 0c4da04 commit 963dd54
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 22 deletions.
14 changes: 1 addition & 13 deletions spot-client/src/common/media/av-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default {
const JitsiMeetJS = JitsiMeetJSProvider.get();

// TODO: implementing handling of gum permissions being denied
return this.hasDevicePermission()
return JitsiMeetJS.mediaDevices.isDevicePermissionGranted()
.then(hasPermission => {
if (hasPermission) {
return Promise.resolve();
Expand Down Expand Up @@ -128,18 +128,6 @@ export default {
return JitsiMeetJSProvider.get().events.track;
},

/**
* Returns whether or not permission has been granted to use audio and
* video.
*
* @returns {boolean}
*/
hasDevicePermission() {
const JitsiMeetJS = JitsiMeetJSProvider.get();

return JitsiMeetJS.mediaDevices.isDevicePermissionGranted();
},

/**
* Be notified when a new camera device has been connected or disconnected.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,7 @@ class SelectMedia extends React.Component {
* @returns {void}
*/
_getDevices() {
avUtils.hasDevicePermission()
.then(hasPermission => {
if (!hasPermission) {
// Force device permission request.
return avUtils.createLocalTracks()
.then(tracks => tracks.forEach(track => track.dispose()));
}
})
.then(() => avUtils.enumerateDevices())
avUtils.enumerateDevices()
.then(this._onDeviceListChange);
}

Expand Down

0 comments on commit 963dd54

Please sign in to comment.