UNPKG

react-native-chating-ui-kit

Version:

CometChat React Native UI Kit is a collection of custom UI Components designed to build text , chat and calling features in your application. The UI Kit is developed to keep developers in mind and aims to reduce development efforts significantly

41 lines 1.85 kB
import React, { useContext, useEffect, useRef, useState } from 'react'; import { ActivityIndicator, View } from 'react-native'; import { CometChat } from "@cometchat-pro/react-native-chat"; import { CometChatContext } from '../../shared/CometChatContext'; import { CallingPackage } from '../CallingPackage'; const CometChatCalls = CallingPackage.CometChatCalls; export const CometChatOngoingCall = (props) => { const { callSettingsBuilder, onError, ongoingCallStyle, sessionID, } = props; const [callToken, setToken] = useState(undefined); const callSettings = useRef(callSettingsBuilder?.build()); const { theme } = useContext(CometChatContext); useEffect(() => { CometChat.getLoggedinUser() .then(user => { let authToken = user.getAuthToken(); CometChatCalls.generateToken(sessionID, authToken) .then(token => { setToken(token.token); }) .catch(rej => { setToken(undefined); onError && onError(rej); }); }) .catch(rej => { console.log("Error", rej); onError && onError(rej); }); return () => { callSettings.current = null; }; }, []); return (<View style={[{ height: '100%', width: '100%', position: 'relative' }, ongoingCallStyle]}> {callSettings.current && callToken && <CometChatCalls.Component callSettings={callSettings.current} callToken={callToken}/> || <View style={{ justifyContent: "center", alignItems: "center", height: "100%", backgroundColor: "transparent" }}> <ActivityIndicator size={"large"} color={theme.palette.getPrimary()}/> </View>} </View>); }; //# sourceMappingURL=CometChatOngoingCall.js.map