Hide call button from RoomInfo if has e2ee warning

This commit is contained in:
Diego Mello 2024-05-14 16:57:24 -03:00
parent 119666a0ac
commit b7ace4ca38
2 changed files with 18 additions and 1 deletions

View File

@ -9,6 +9,7 @@ import { useVideoConf } from '../../../lib/hooks/useVideoConf';
import { useTheme } from '../../../theme';
import styles from '../styles';
import { compareServerVersion } from '../../../lib/methods/helpers';
import { useE2EEWarning } from '../hooks';
function BaseButton({
danger,
@ -89,6 +90,7 @@ export const RoomInfoButtons = ({
const isDirectFromSaved = isDirect && fromRid && room;
const isIgnored = room?.ignored?.includes?.(roomUserId || '');
const isBlocked = room?.blocker;
const hasE2EEWarning = useE2EEWarning(room);
const renderIgnoreUser = isDirectFromSaved && !isFromDm && !isDmWithMyself;
const renderBlockUser = !itsMe && isDirectFromSaved && isFromDm && !isDmWithMyself;
@ -98,7 +100,7 @@ export const RoomInfoButtons = ({
return (
<View style={styles.roomButtonsContainer}>
<BaseButton onPress={handleCreateDirectMessage} label={i18n.t('Message')} iconName='message' />
<CallButton isDirect={isDirect} rid={rid} roomFromRid={!!roomFromRid} />
{hasE2EEWarning ? null : <CallButton isDirect={isDirect} rid={rid} roomFromRid={!!roomFromRid} />}
<BaseButton
onPress={handleIgnoreUser}
label={i18n.t(isIgnored ? 'Unignore' : 'Ignore')}

View File

@ -0,0 +1,15 @@
import { ISubscription } from '../../definitions';
import { hasE2EEWarning } from '../../lib/encryption/utils';
import { useAppSelector } from '../../lib/hooks';
export const useE2EEWarning = (room?: ISubscription): boolean => {
const encryptionEnabled = useAppSelector(state => state.encryption.enabled);
if (!room) {
return false;
}
return hasE2EEWarning({
encryptionEnabled,
E2EKey: room.E2EKey,
roomEncrypted: room.encrypted
});
};