fix permissions

This commit is contained in:
GleidsonDaniel 2023-03-02 11:24:39 -03:00
parent 1fb060a982
commit 7a1aa58925
2 changed files with 11 additions and 9 deletions

View File

@ -1,5 +1,6 @@
import React, { useEffect, useState } from 'react';
import { Q } from '@nozbe/watermelondb'; import { Q } from '@nozbe/watermelondb';
import { Camera } from 'expo-camera';
import React, { useEffect, useState } from 'react';
import { useActionSheet } from '../../containers/ActionSheet'; import { useActionSheet } from '../../containers/ActionSheet';
import StartACallActionSheet from '../../containers/UIKit/VideoConferenceBlock/components/StartACallActionSheet'; import StartACallActionSheet from '../../containers/UIKit/VideoConferenceBlock/components/StartACallActionSheet';
@ -10,7 +11,7 @@ import database from '../database';
import { getSubscriptionByRoomId } from '../database/services/Subscription'; import { getSubscriptionByRoomId } from '../database/services/Subscription';
import { callJitsi } from '../methods'; import { callJitsi } from '../methods';
import { compareServerVersion, showErrorAlert } from '../methods/helpers'; import { compareServerVersion, showErrorAlert } from '../methods/helpers';
import { handleCallPermissions, videoConfStartAndJoin } from '../methods/videoConf'; import { handleAndroidBltPermission, videoConfStartAndJoin } from '../methods/videoConf';
import { Services } from '../services'; import { Services } from '../services';
import { useAppSelector } from './useAppSelector'; import { useAppSelector } from './useAppSelector';
import { useSnaps } from './useSnaps'; import { useSnaps } from './useSnaps';
@ -35,6 +36,8 @@ export const useVideoConf = (rid: string): { showInitCallActionSheet: () => Prom
const jitsiEnableChannels = useAppSelector(state => state.settings.Jitsi_Enable_Channels); const jitsiEnableChannels = useAppSelector(state => state.settings.Jitsi_Enable_Channels);
const user = useAppSelector(state => getUserSelector(state)); const user = useAppSelector(state => getUserSelector(state));
const [permission, requestPermission] = Camera.useCameraPermissions();
const isServer5OrNewer = compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '5.0.0'); const isServer5OrNewer = compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '5.0.0');
const { showActionSheet } = useActionSheet(); const { showActionSheet } = useActionSheet();
@ -87,7 +90,10 @@ export const useVideoConf = (rid: string): { showInitCallActionSheet: () => Prom
children: <StartACallActionSheet rid={rid} initCall={initCall} />, children: <StartACallActionSheet rid={rid} initCall={initCall} />,
snaps snaps
}); });
handleCallPermissions(); if (!permission?.granted) {
requestPermission();
handleAndroidBltPermission();
}
} }
}; };

View File

@ -19,14 +19,10 @@ const handleBltPermission = async (): Promise<Permission[]> => {
return [PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION]; return [PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION];
}; };
export const handleCallPermissions = async (): Promise<void> => { export const handleAndroidBltPermission = async (): Promise<void> => {
if (isAndroid) { if (isAndroid) {
const bltPermission = await handleBltPermission(); const bltPermission = await handleBltPermission();
await PermissionsAndroid.requestMultiple([ await PermissionsAndroid.requestMultiple(bltPermission);
PermissionsAndroid.PERMISSIONS.CAMERA,
PermissionsAndroid.PERMISSIONS.RECORD_AUDIO,
...bltPermission
]);
} }
}; };