feat(permissions): adjust to changes in permissions checking
This commit is contained in:
parent
8282873de5
commit
b673c4a11a
|
@ -5,7 +5,7 @@ import React from 'react';
|
||||||
import { AbstractDialogTab } from '../../base/dialog';
|
import { AbstractDialogTab } from '../../base/dialog';
|
||||||
import type { Props as AbstractDialogTabProps } from '../../base/dialog';
|
import type { Props as AbstractDialogTabProps } from '../../base/dialog';
|
||||||
import { translate } from '../../base/i18n';
|
import { translate } from '../../base/i18n';
|
||||||
import { createLocalTrack } from '../../base/lib-jitsi-meet';
|
import JitsiMeetJS, { createLocalTrack } from '../../base/lib-jitsi-meet';
|
||||||
|
|
||||||
import AudioInputPreview from './AudioInputPreview';
|
import AudioInputPreview from './AudioInputPreview';
|
||||||
import AudioOutputPreview from './AudioOutputPreview';
|
import AudioOutputPreview from './AudioOutputPreview';
|
||||||
|
@ -40,18 +40,6 @@ export type Props = {
|
||||||
*/
|
*/
|
||||||
disableDeviceChange: boolean,
|
disableDeviceChange: boolean,
|
||||||
|
|
||||||
/**
|
|
||||||
* Function that checks whether or not a new audio input source can be
|
|
||||||
* selected.
|
|
||||||
*/
|
|
||||||
hasAudioPermission: Function,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function that checks whether or not a new video input sources can be
|
|
||||||
* selected.
|
|
||||||
*/
|
|
||||||
hasVideoPermission: Function,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If true, the audio meter will not display. Necessary for browsers or
|
* If true, the audio meter will not display. Necessary for browsers or
|
||||||
* configurations that do not support local stats to prevent a
|
* configurations that do not support local stats to prevent a
|
||||||
|
@ -98,6 +86,16 @@ export type Props = {
|
||||||
*/
|
*/
|
||||||
type State = {
|
type State = {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether or not the audio permission was granted.
|
||||||
|
*/
|
||||||
|
hasAudioPermission: boolean,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether or not the audio permission was granted.
|
||||||
|
*/
|
||||||
|
hasVideoPermission: boolean,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The JitsiTrack to use for previewing audio input.
|
* The JitsiTrack to use for previewing audio input.
|
||||||
*/
|
*/
|
||||||
|
@ -130,6 +128,8 @@ class DeviceSelection extends AbstractDialogTab<Props, State> {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
|
hasAudioPermission: false,
|
||||||
|
hasVideoPermission: false,
|
||||||
previewAudioTrack: null,
|
previewAudioTrack: null,
|
||||||
previewVideoTrack: null,
|
previewVideoTrack: null,
|
||||||
previewVideoTrackError: null
|
previewVideoTrackError: null
|
||||||
|
@ -150,6 +150,32 @@ class DeviceSelection extends AbstractDialogTab<Props, State> {
|
||||||
.then(() => this.props.mountCallback && this.props.mountCallback());
|
.then(() => this.props.mountCallback && this.props.mountCallback());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if audio / video permissions were granted.
|
||||||
|
*
|
||||||
|
* @param {Object} prevProps - Previous props this component received.
|
||||||
|
* @param {Object} prevState - Previous state this component had.
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
componentDidUpdate(prevProps, prevState) {
|
||||||
|
const { previewAudioTrack, previewVideoTrack } = prevState;
|
||||||
|
|
||||||
|
if ((!previewAudioTrack && this.state.previewAudioTrack)
|
||||||
|
|| (!previewVideoTrack && this.state.previewVideoTrack)) {
|
||||||
|
Promise.all([
|
||||||
|
JitsiMeetJS.mediaDevices.isDevicePermissionGranted('audio'),
|
||||||
|
JitsiMeetJS.mediaDevices.isDevicePermissionGranted('video')
|
||||||
|
]).then(r => {
|
||||||
|
const [ hasAudioPermission, hasVideoPermission ] = r;
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
hasAudioPermission,
|
||||||
|
hasVideoPermission
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates audio input and video input previews.
|
* Updates audio input and video input previews.
|
||||||
*
|
*
|
||||||
|
@ -316,11 +342,12 @@ class DeviceSelection extends AbstractDialogTab<Props, State> {
|
||||||
*/
|
*/
|
||||||
_renderSelectors() {
|
_renderSelectors() {
|
||||||
const { availableDevices } = this.props;
|
const { availableDevices } = this.props;
|
||||||
|
const { hasAudioPermission, hasVideoPermission } = this.state;
|
||||||
|
|
||||||
const configurations = [
|
const configurations = [
|
||||||
{
|
{
|
||||||
devices: availableDevices.videoInput,
|
devices: availableDevices.videoInput,
|
||||||
hasPermission: this.props.hasVideoPermission(),
|
hasPermission: hasVideoPermission,
|
||||||
icon: 'icon-camera',
|
icon: 'icon-camera',
|
||||||
isDisabled: this.props.disableDeviceChange,
|
isDisabled: this.props.disableDeviceChange,
|
||||||
key: 'videoInput',
|
key: 'videoInput',
|
||||||
|
@ -331,7 +358,7 @@ class DeviceSelection extends AbstractDialogTab<Props, State> {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
devices: availableDevices.audioInput,
|
devices: availableDevices.audioInput,
|
||||||
hasPermission: this.props.hasAudioPermission(),
|
hasPermission: hasAudioPermission,
|
||||||
icon: 'icon-microphone',
|
icon: 'icon-microphone',
|
||||||
isDisabled: this.props.disableAudioInputChange
|
isDisabled: this.props.disableAudioInputChange
|
||||||
|| this.props.disableDeviceChange,
|
|| this.props.disableDeviceChange,
|
||||||
|
@ -346,8 +373,7 @@ class DeviceSelection extends AbstractDialogTab<Props, State> {
|
||||||
if (!this.props.hideAudioOutputSelect) {
|
if (!this.props.hideAudioOutputSelect) {
|
||||||
configurations.push({
|
configurations.push({
|
||||||
devices: availableDevices.audioOutput,
|
devices: availableDevices.audioOutput,
|
||||||
hasPermission: this.props.hasAudioPermission()
|
hasPermission: hasAudioPermission || hasVideoPermission,
|
||||||
|| this.props.hasVideoPermission(),
|
|
||||||
icon: 'icon-speaker',
|
icon: 'icon-speaker',
|
||||||
isDisabled: this.props.disableDeviceChange,
|
isDisabled: this.props.disableDeviceChange,
|
||||||
key: 'audioOutput',
|
key: 'audioOutput',
|
||||||
|
|
|
@ -20,10 +20,6 @@ export function getDeviceSelectionDialogProps(stateful: Object | Function) {
|
||||||
!JitsiMeetJS.isMultipleAudioInputSupported(),
|
!JitsiMeetJS.isMultipleAudioInputSupported(),
|
||||||
disableDeviceChange:
|
disableDeviceChange:
|
||||||
!JitsiMeetJS.mediaDevices.isDeviceChangeAvailable(),
|
!JitsiMeetJS.mediaDevices.isDeviceChangeAvailable(),
|
||||||
hasAudioPermission: JitsiMeetJS.mediaDevices
|
|
||||||
.isDevicePermissionGranted.bind(null, 'audio'),
|
|
||||||
hasVideoPermission: JitsiMeetJS.mediaDevices
|
|
||||||
.isDevicePermissionGranted.bind(null, 'video'),
|
|
||||||
hideAudioInputPreview:
|
hideAudioInputPreview:
|
||||||
!JitsiMeetJS.isCollectingLocalStats(),
|
!JitsiMeetJS.isCollectingLocalStats(),
|
||||||
hideAudioOutputSelect: !JitsiMeetJS.mediaDevices
|
hideAudioOutputSelect: !JitsiMeetJS.mediaDevices
|
||||||
|
|
|
@ -64,10 +64,6 @@ export default class DeviceSelectionPopup {
|
||||||
disableAudioInputChange: true,
|
disableAudioInputChange: true,
|
||||||
disableBlanketClickDismiss: true,
|
disableBlanketClickDismiss: true,
|
||||||
disableDeviceChange: true,
|
disableDeviceChange: true,
|
||||||
hasAudioPermission: JitsiMeetJS.mediaDevices
|
|
||||||
.isDevicePermissionGranted.bind(null, 'audio'),
|
|
||||||
hasVideoPermission: JitsiMeetJS.mediaDevices
|
|
||||||
.isDevicePermissionGranted.bind(null, 'video'),
|
|
||||||
hideAudioInputPreview: !JitsiMeetJS.isCollectingLocalStats(),
|
hideAudioInputPreview: !JitsiMeetJS.isCollectingLocalStats(),
|
||||||
hideAudioOutputSelect: true
|
hideAudioOutputSelect: true
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue