[captureMode] conver string captureMode prop, only check audio permission if in video mode

This commit is contained in:
Zack Story 2016-04-03 12:29:58 -07:00 committed by Zack Story
parent 0c789b8da0
commit 921965208f
No known key found for this signature in database
GPG Key ID: 9057E38B6937BF11

View File

@ -38,6 +38,10 @@ function convertStringProps(props) {
newProps.captureQuality = Camera.constants.CaptureQuality[props.captureQuality];
}
if (typeof props.captureMode === 'string') {
newProps.captureMode = Camera.constants.CaptureMode[props.captureMode];
}
return newProps;
}
@ -133,7 +137,9 @@ export default class Camera extends Component {
async componentWillMount() {
this.cameraBarCodeReadListener = NativeAppEventEmitter.addListener('CameraBarCodeRead', this.props.onBarCodeRead);
let check = this.props.captureAudio ? Camera.checkDeviceAuthorizationStatus : Camera.checkVideoAuthorizationStatus;
let { captureMode } = convertStringProps({captureMode: this.props.captureMode})
let hasVideoAndAudio = this.props.captureAudio && captureMode === Camera.constants.CaptureMode.video
let check = hasVideoAndAudio ? Camera.checkDeviceAuthorizationStatus : Camera.checkVideoAuthorizationStatus;
if (check) {
const isAuthorized = await check();