Rocket.Chat.ReactNative/app/lib/methods/videoConf.ts

49 lines
1.5 KiB
TypeScript
Raw Normal View History

import { PermissionsAndroid, Permission } from 'react-native';
import DeviceInfo from 'react-native-device-info';
import i18n from '../../i18n';
import navigation from '../navigation/appNavigation';
import { Services } from '../services';
import { isAndroid, showErrorAlert } from './helpers';
import log from './helpers/log';
import openLink from './helpers/openLink';
const handleBltPermission = async (): Promise<Permission[]> => {
const systemVersion = await DeviceInfo.getApiLevel();
if (systemVersion <= 28) {
return [PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT, PermissionsAndroid.PERMISSIONS.BLUETOOTH_SCAN];
}
if (systemVersion === 29) {
return [PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION];
}
return [PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION];
};
feat: Add caller and ringer to video conf calls (#5046) * add expo camera and use camera on call init action sheet * fix permissions * set colors when calling * update @react-native-community/hooks lib * move to useWindowDimensions * create action to handle video-conf calls * create videoConf reducer * add typed-redux-saga lib * fix return * change videoConf saga to TS * fix TS target * update action and types * create actionSheetRef * add notifyUser api * export video conf types * add action prop * use new reducer prop * add videoConferenceCancel and add allowRinging to videoConferenceStart * temp-patch * add locales * add handler to videoconf message * fix rest types * add message types * path to remove component from dom * remove notification when is videoconf * create sound hook * create dots loader * update call translation * the end is near * move to confirmed * better code reading * fix call type * fix tests * update podfile * wip * fix call order * move colors * move to jsx * fix colors * add pt-br * remove patch and point * fix colors * fix expo camera * move to style * remove unused styles * update types and style * wip * rename IncomingCallComponent * add custom notification * wip * fix naming * fix styles * fix import * fix styles * change colors * fixa ringing * fix import * organize * fix sizes * use realName * fix spacing * fix icon size * fix header gap * changeColor * fix safeArea * set calling only on direct calls * change ringer to be a component * cancel call on swipe * remove join on direct calls * add props * update package
2023-07-04 00:03:39 +00:00
export const handleAndroidBltPermission = async (): Promise<void> => {
if (isAndroid) {
const bltPermission = await handleBltPermission();
await PermissionsAndroid.requestMultiple(bltPermission);
}
};
2023-11-24 12:46:58 +00:00
export const videoConfJoin = async (callId: string, cam?: boolean, mic?: boolean, fromPush?: boolean): Promise<void> => {
try {
const result = await Services.videoConferenceJoin(callId, cam, mic);
if (result.success) {
const { url, providerName } = result;
if (providerName === 'jitsi') {
navigation.navigate('JitsiMeetView', { url, onlyAudio: !cam, videoConf: true });
} else {
openLink(url);
}
}
} catch (e) {
2023-11-24 12:46:58 +00:00
if (fromPush) {
showErrorAlert(i18n.t('Missed_call'));
} else {
showErrorAlert(i18n.t('error-init-video-conf'));
}
log(e);
}
};