import React, { useState } from 'react'; import { Text, View, useWindowDimensions } from 'react-native'; import Touchable from 'react-native-platform-touchable'; import { useSafeAreaInsets } from 'react-native-safe-area-context'; import { useDispatch } from 'react-redux'; import { acceptCall, cancelCall } from '../../../actions/videoConf'; import { ISubscription, SubscriptionType } from '../../../definitions'; import i18n from '../../../i18n'; import { useAppSelector } from '../../../lib/hooks'; import { useEndpointData } from '../../../lib/hooks/useEndpointData'; import { hideNotification } from '../../../lib/methods/helpers/notifications'; import { useTheme } from '../../../theme'; import { CustomIcon } from '../../CustomIcon'; import { CallHeader } from '../../CallHeader'; import { useStyle } from './style'; import useUserData from '../../../lib/hooks/useUserData'; import Ringer, { ERingerSounds } from '../../Ringer'; export interface INotifierComponent { notification: { text: string; payload: { sender: { username: string }; type: SubscriptionType; } & Pick; title: string; avatar: string; }; isMasterDetail: boolean; } const BUTTON_HIT_SLOP = { top: 12, right: 12, bottom: 12, left: 12 }; const IncomingCallHeader = React.memo( ({ uid, callId, avatar, roomName }: { callId: string; avatar: string; uid: string; roomName: string }) => { const [mic, setMic] = useState(true); const [cam, setCam] = useState(false); const dispatch = useDispatch(); const isMasterDetail = useAppSelector(state => state.app.isMasterDetail); const styles = useStyle(); const insets = useSafeAreaInsets(); const { height, width } = useWindowDimensions(); const isLandscape = width > height; const { colors } = useTheme(); return ( { hideNotification(); dispatch(cancelCall({ callId })); }} style={styles.cancelButton} > {i18n.t('decline')} { hideNotification(); dispatch(acceptCall({ callId })); }} style={styles.acceptButton} > {i18n.t('accept')} ); } ); const IncomingCallNotification = ({ notification: { rid, callId } }: { notification: { rid: string; callId: string }; }): React.ReactElement | null => { const { result } = useEndpointData('video-conference.info', { callId }); const user = useUserData(rid); if (result?.success && user.username) { return ; } return null; }; export default IncomingCallNotification;