This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState, useEffect, useContext } from 'react'; | |
import { IonToolbar, IonTitle, IonHeader, IonButtons, IonBackButton } from '@ionic/react'; | |
import { useHistory } from 'react-router'; | |
import { v4 as uuidv4 } from "uuid"; | |
import Context from '../context'; | |
const RemoveGroupMembers: React.FC = () => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
const logout = () => { | |
const shouldLogout = window.confirm('Do you want to logout'); | |
if (shouldLogout) { | |
setIsLoading(true); | |
cometChat.logout().then( | |
() => { | |
setUser(null); | |
setSelectedConversation(null); | |
localStorage.removeItem('auth'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// import react. | |
import React from 'react'; | |
// import react router. | |
import { Route, Redirect } from 'react-router-dom'; | |
const PrivateRoute: React.FC<any> = ({ component: Component, ...rest }: any) => { | |
return ( | |
// Show the component only when the user is logged in | |
// Otherwise, redirect the user to /signin page | |
<Route {...rest} render={props => ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
useEffect(() => { | |
... | |
return () => { | |
... | |
if (cometChat) { | |
... | |
cometChat.removeGroupListener(groupListenerId); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
const handleDeleteGroup = () => { | |
if (selectedConversation && selectedConversation.name && selectedConversation.guid) { | |
setIsLoading(true); | |
cometChat.deleteGroup(selectedConversation.guid).then( | |
(response: any) => { | |
setIsLoading(false); | |
alert(`${selectedConversation.name} was deleted successfully`); | |
history.push('/'); | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
useEffect(() => { | |
initCometChat(); | |
}, []); | |
const initCometChat = async () => { | |
const { CometChat } = await import('@cometchat-pro/chat'); | |
const appID = `${process.env.REACT_APP_COMETCHAT_APP_ID}`; | |
const region = `${process.env.REACT_APP_COMETCHAT_REGION}`; | |
const appSetting = new CometChat.AppSettingsBuilder().subscribePresenceForAllUsers().setRegion(region).build(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import firebase from "firebase"; | |
import "firebase/storage"; | |
const firebaseConfig = { | |
apiKey: `${process.env.REACT_APP_FIREBASE_API_KEY}`, | |
authDomain: `${process.env.REACT_APP_FIREBASE_AUTH_DOMAIN}`, | |
databaseURL: `${process.env.REACT_APP_FIREBASE_DATABASE_URL}`, | |
projectId: `${process.env.REACT_APP_FIREBASE_PROJECT_ID}`, | |
storageBucket: `${process.env.REACT_APP_FIREBASE_STORAGE_BUCKET}`, | |
messagingSenderId: `${process.env.REACT_APP_FIREABSE_MESSAGING_SENDER_ID}`, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
export default React.createContext(null); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useRef, useContext, useEffect } from "react"; | |
import Context from "../context"; | |
import { auth, realTimeDb } from "../firebase"; | |
import validator from "validator"; | |
import withModal from "./Modal"; | |
import SignUp from "./SignUp"; | |
import { useHistory } from 'react-router-dom'; | |
import { v4 as uuidv4 } from "uuid"; | |
const Login = (props) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
const keys = Object.keys(val); | |
const user = val[keys[0]]; | |
cometChat.login(user.id, `${process.env.REACT_APP_COMETCHAT_AUTH_KEY}`).then( | |
User => { | |
... | |
}, | |
error => { | |
} | |
); |