2022-12-01 17:20:22 +00:00
|
|
|
import { PermissionsAndroid } from 'react-native';
|
|
|
|
|
|
|
|
import i18n from '../../i18n';
|
2022-06-27 18:04:20 +00:00
|
|
|
import navigation from '../navigation/appNavigation';
|
|
|
|
import { Services } from '../services';
|
2022-12-01 17:20:22 +00:00
|
|
|
import { isAndroid, showErrorAlert } from './helpers';
|
2022-06-27 18:04:20 +00:00
|
|
|
import log from './helpers/log';
|
2022-12-01 17:20:22 +00:00
|
|
|
import openLink from './helpers/openLink';
|
2022-06-27 18:04:20 +00:00
|
|
|
|
|
|
|
export const videoConfJoin = async (callId: string, cam: boolean) => {
|
|
|
|
try {
|
|
|
|
const result = await Services.videoConferenceJoin(callId, cam);
|
|
|
|
if (result.success) {
|
2022-12-01 17:20:22 +00:00
|
|
|
if (isAndroid) {
|
|
|
|
await PermissionsAndroid.requestMultiple([
|
|
|
|
PermissionsAndroid.PERMISSIONS.CAMERA,
|
|
|
|
PermissionsAndroid.PERMISSIONS.RECORD_AUDIO
|
|
|
|
]);
|
|
|
|
}
|
2022-06-27 18:04:20 +00:00
|
|
|
const { url, providerName } = result;
|
|
|
|
if (providerName === 'jitsi') {
|
|
|
|
navigation.navigate('JitsiMeetView', { url, onlyAudio: !cam, videoConf: true });
|
|
|
|
} else {
|
|
|
|
openLink(url);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
showErrorAlert(i18n.t('error-init-video-conf'));
|
|
|
|
log(e);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export const videoConfStartAndJoin = async (rid: string, cam: boolean) => {
|
|
|
|
try {
|
|
|
|
const videoConfResponse: any = await Services.videoConferenceStart(rid);
|
|
|
|
if (videoConfResponse.success) {
|
|
|
|
videoConfJoin(videoConfResponse.data.callId, cam);
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
showErrorAlert(i18n.t('error-init-video-conf'));
|
|
|
|
log(e);
|
|
|
|
}
|
|
|
|
};
|