fix: enable video call initiation only for direct messages (#5472)
This commit is contained in:
parent
ec3cb3ac53
commit
c5fe22c506
|
@ -1,8 +1,8 @@
|
|||
import { Camera, CameraType } from 'expo-camera';
|
||||
import React, { useState } from 'react';
|
||||
import { StyleSheet, View } from 'react-native';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
||||
import { useDispatch } from 'react-redux';
|
||||
|
||||
import { useAppSelector } from '..';
|
||||
import { cancelCall, initVideoCall } from '../../../actions/videoConf';
|
||||
|
@ -10,12 +10,19 @@ import AvatarContainer from '../../../containers/Avatar';
|
|||
import Button from '../../../containers/Button';
|
||||
import { CallHeader } from '../../../containers/CallHeader';
|
||||
import Ringer, { ERingerSounds } from '../../../containers/Ringer';
|
||||
import { SubscriptionType } from '../../../definitions';
|
||||
import i18n from '../../../i18n';
|
||||
import { getUserSelector } from '../../../selectors/login';
|
||||
import { useTheme } from '../../../theme';
|
||||
import useUserData from '../useUserData';
|
||||
|
||||
export default function StartACallActionSheet({ rid }: { rid: string }): React.ReactElement {
|
||||
export default function StartACallActionSheet({
|
||||
rid,
|
||||
roomType
|
||||
}: {
|
||||
rid: string;
|
||||
roomType?: SubscriptionType;
|
||||
}): React.ReactElement {
|
||||
const { colors } = useTheme();
|
||||
const [mic, setMic] = useState(true);
|
||||
const [cam, setCam] = useState(false);
|
||||
|
@ -42,7 +49,7 @@ export default function StartACallActionSheet({ rid }: { rid: string }): React.R
|
|||
style={[style.actionSheetContainer, { paddingBottom: bottom }]}
|
||||
onLayout={e => setContainerWidth(e.nativeEvent.layout.width / 2)}
|
||||
>
|
||||
{calling ? <Ringer ringer={ERingerSounds.DIALTONE} /> : null}
|
||||
{calling && roomType === SubscriptionType.DIRECT ? <Ringer ringer={ERingerSounds.DIALTONE} /> : null}
|
||||
<CallHeader
|
||||
title={calling && user.direct ? i18n.t('Calling') : i18n.t('Start_a_call')}
|
||||
cam={cam}
|
||||
|
|
|
@ -31,7 +31,7 @@ export const useVideoConf = (
|
|||
const user = useAppSelector(state => getUserSelector(state));
|
||||
const serverVersion = useAppSelector(state => state.server.version);
|
||||
|
||||
const { callEnabled, disabledTooltip } = useVideoConfCall(rid);
|
||||
const { callEnabled, disabledTooltip, roomType } = useVideoConfCall(rid);
|
||||
|
||||
const [permission, requestPermission] = Camera.useCameraPermissions();
|
||||
const { showActionSheet } = useActionSheet();
|
||||
|
@ -59,7 +59,7 @@ export const useVideoConf = (
|
|||
const canInit = await canInitAnCall();
|
||||
if (canInit) {
|
||||
showActionSheet({
|
||||
children: <StartACallActionSheet rid={rid} />,
|
||||
children: <StartACallActionSheet rid={rid} roomType={roomType} />,
|
||||
snaps: [480]
|
||||
});
|
||||
|
||||
|
|
|
@ -3,15 +3,18 @@ import { useEffect, useState } from 'react';
|
|||
import { SubscriptionType } from '../../../definitions';
|
||||
import { getUserSelector } from '../../../selectors/login';
|
||||
import { getSubscriptionByRoomId } from '../../database/services/Subscription';
|
||||
import { isRoomFederated } from '../../methods';
|
||||
import { compareServerVersion, isReadOnly } from '../../methods/helpers';
|
||||
import { useAppSelector } from '../useAppSelector';
|
||||
import { usePermissions } from '../usePermissions';
|
||||
import { useSetting } from '../useSetting';
|
||||
import { isRoomFederated } from '../../methods';
|
||||
|
||||
export const useVideoConfCall = (rid: string): { callEnabled: boolean; disabledTooltip?: boolean } => {
|
||||
export const useVideoConfCall = (
|
||||
rid: string
|
||||
): { callEnabled: boolean; disabledTooltip?: boolean; roomType?: SubscriptionType } => {
|
||||
const [callEnabled, setCallEnabled] = useState(false);
|
||||
const [disabledTooltip, setDisabledTooltip] = useState(false);
|
||||
const [roomType, setRoomType] = useState<SubscriptionType>();
|
||||
|
||||
// OLD SETTINGS
|
||||
const jitsiEnabled = useSetting('Jitsi_Enabled');
|
||||
|
@ -34,6 +37,7 @@ export const useVideoConfCall = (rid: string): { callEnabled: boolean; disabledT
|
|||
const init = async () => {
|
||||
const room = await getSubscriptionByRoomId(rid);
|
||||
if (room) {
|
||||
setRoomType(room.t);
|
||||
if (isServer5OrNewer) {
|
||||
const isReadyOnly = await isReadOnly(room, user.username);
|
||||
const ownUser = room.uids && room.uids.length === 1;
|
||||
|
@ -64,5 +68,5 @@ export const useVideoConfCall = (rid: string): { callEnabled: boolean; disabledT
|
|||
init();
|
||||
}, []);
|
||||
|
||||
return { callEnabled, disabledTooltip };
|
||||
return { callEnabled, disabledTooltip, roomType };
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue