Skip to content
This repository has been archived by the owner on May 2, 2022. It is now read-only.

Commit

Permalink
#33 use cloud function for message notification
Browse files Browse the repository at this point in the history
  • Loading branch information
gkillick committed Mar 31, 2022
1 parent c8c3309 commit 4d79de2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion functions/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export {requestDoctor, dispatchDoctor, sendNotification} from "./callable";
export {requestDoctor, dispatchDoctor, sendNotification, sendNotificationForConversation} from "./callable";


// // Start writing Firebase Functions
Expand Down
10 changes: 9 additions & 1 deletion src/components/chat/chatroom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { doc, onSnapshot, Timestamp } from 'firebase/firestore';
import { Avatar, Box, Button, Grid, Typography } from '@mui/material';
import firebase from 'firebase/compat/app';
import SendIcon from '@mui/icons-material/Send';
import { firestore } from '../../config/firebase_config';
import Firebase, { firestore } from '../../config/firebase_config';
import { UserContext } from '../../context/UserContext';
import { PatientData } from '../dashboard/MedicalView/PatientInfo/PatientInfo';
import './chatroom.css';
Expand Down Expand Up @@ -79,6 +79,14 @@ function ChatRoom(props: ChatInfo) {
unreadUserIds: firebase.firestore.FieldValue.arrayUnion(props.recipientID),
});

const sendNotification = Firebase.functions().httpsCallable('sendNotificationForConversation');
sendNotification({
title: 'New Message',
message: `Unread message from ${state.firstName} ${state.lastName}`,
recipientID: props.recipientID,
conversationID: props.patientID,
});

setFormValue('');
};

Expand Down

0 comments on commit 4d79de2

Please sign in to comment.