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<any>(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 React, { useRef, useContext } from 'react'; | |
import { useHistory } from 'react-router'; | |
import validator from "validator"; | |
import { auth } from "../firebase"; | |
import Context from '../context'; | |
const Login: React.FC = () => { | |
// get shared data from context. |
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
... | |
cometChat.login(firebaseUid, `${process.env.REACT_APP_COMETCHAT_AUTH_KEY}`).then( | |
(User: any) => { | |
// User loged in successfully. | |
// save authenticated user to local storage. | |
localStorage.setItem('auth', JSON.stringify(User)); | |
// save authenticated user to context. | |
setUser(User); | |
// hide loading. | |
setIsLoading(false); |
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, { useRef, useContext } from 'react'; | |
import { IonToolbar, IonTitle, IonButtons, IonBackButton, IonHeader } from '@ionic/react'; | |
import validator from "validator"; | |
import { auth } from '../firebase'; | |
import Context from '../context'; | |
const SignUp: React.FC<any> = () => { |
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
... | |
// cometchat auth key | |
const authKey = `${process.env.REACT_APP_COMETCHAT_AUTH_KEY}`; | |
// call cometchat service to register a new account. | |
const user = new cometChat.User(firebaseUid); | |
user.setName(fullname); | |
user.setAvatar(userAvatar); | |
cometChat.createUser(user, authKey).then( | |
(user: any) => { |
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, { useRef, useContext, useState, useEffect, useCallback } from 'react'; | |
import { IonToolbar, IonTitle, IonHeader, IonButtons, IonButton, IonIcon } from '@ionic/react'; | |
import { add, exit } from 'ionicons/icons'; | |
import { useHistory } from 'react-router'; | |
import { v4 as uuidv4 } from "uuid"; | |
import Context from '../context'; |
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(() => { | |
if (cometChat) { | |
listenForMessages(); | |
} | |
return () => { | |
if (cometChat) { | |
cometChat.removeMessageListener(listenerID); | |
} | |
setData(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
... | |
const joinGroup = (item: any) => { | |
if (item && item.guid && !item.hasJoined) { | |
setIsLoading(true); | |
const GUID = item.guid; | |
const password = ""; | |
const groupType = cometChat.GROUP_TYPE.PUBLIC; | |
cometChat.joinGroup(GUID, groupType, password).then( | |
(group: any) => { |
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, { useRef, useContext } from 'react'; | |
import { IonToolbar, IonTitle, IonHeader, IonButtons, IonBackButton } from '@ionic/react'; | |
import validator from "validator"; | |
import { v4 as uuidv4 } from "uuid"; | |
import Context from '../context'; | |
const CreateGroup: 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 createGroup = () => { | |
const groupName = groupNameRef.current.value; | |
if (isGroupValid(groupName)) { | |
setIsLoading(true); | |
const GUID = uuidv4(); | |
const groupType = cometChat.GROUP_TYPE.PUBLIC; | |
const groupIcon = generateAvatar(); | |
const password = ""; |