voicebot-react-native-expo
Version:
This is a voicebot-react-native package of Kipps AI voice bot for React Native Expo
30 lines (25 loc) • 857 B
text/typescript
import * as React from 'react';
import { LocalParticipant } from 'livekit-client';
import type { Participant, Room } from 'livekit-client';
import { encryptionStatusObservable } from '@livekit/components-core';
import { useEnsureParticipant, useEnsureRoom } from '../context';
import { useObservableState } from './internal';
/**
* @alpha
*/
export interface UseIsEncryptedOptions {
room?: Room;
}
/**
* @alpha
*/
export function useIsEncrypted(participant?: Participant, options: UseIsEncryptedOptions = {}) {
const p = useEnsureParticipant(participant);
const room = useEnsureRoom(options.room);
const observer = React.useMemo(() => encryptionStatusObservable(room, p), [room, p]);
const isEncrypted = useObservableState(
observer,
p instanceof LocalParticipant ? p.isE2EEEnabled : !!p?.isEncrypted,
);
return isEncrypted;
}