Skip to content

Commit

Permalink
fetch vc data on listen notification
Browse files Browse the repository at this point in the history
  • Loading branch information
gkatrakazas committed Dec 3, 2024
1 parent 6e8ebfe commit 90656ed
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/components/Notifications/HandlerNotification.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React, { useState, useEffect, useCallback } from 'react';
import React, { useState, useEffect, useCallback, useContext } from 'react';
import toast, { Toaster } from 'react-hot-toast';
import { onMessageListener } from '../../firebase';
import { AiOutlineClose } from 'react-icons/ai';
import logo from '../../assets/images/logo.png';
import CredentialsContext from '../../context/CredentialsContext';

const ToastDisplay = ({ id, notification }) => {
return (
Expand Down Expand Up @@ -31,6 +32,7 @@ const ToastDisplay = ({ id, notification }) => {

const HandlerNotification = () => {
const [notification, setNotification] = useState({ title: '', body: '' });
const { getData } = useContext(CredentialsContext);

const showToast = useCallback(
() => toast((t) => <ToastDisplay id={t.id} notification={notification} />),
Expand All @@ -50,6 +52,7 @@ const HandlerNotification = () => {
title: payload?.notification?.title,
body: payload?.notification?.body,
});
getData();
})
.catch((err) => {
console.log('Failed to receive message:', err);
Expand All @@ -60,10 +63,10 @@ const HandlerNotification = () => {
messageListener();
}
};
}, []);
}, [getData]);

return (
<Toaster />
<Toaster />
);
};

Expand Down

0 comments on commit 90656ed

Please sign in to comment.