From 90656edacef9f3c17dc27e3e9db7dc300900f5ba Mon Sep 17 00:00:00 2001 From: gkatrakazas Date: Thu, 28 Nov 2024 16:26:18 +0200 Subject: [PATCH] fetch vc data on listen notification --- src/components/Notifications/HandlerNotification.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/Notifications/HandlerNotification.js b/src/components/Notifications/HandlerNotification.js index 3c394f6c..3ab177b1 100644 --- a/src/components/Notifications/HandlerNotification.js +++ b/src/components/Notifications/HandlerNotification.js @@ -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 ( @@ -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) => ), @@ -50,6 +52,7 @@ const HandlerNotification = () => { title: payload?.notification?.title, body: payload?.notification?.body, }); + getData(); }) .catch((err) => { console.log('Failed to receive message:', err); @@ -60,10 +63,10 @@ const HandlerNotification = () => { messageListener(); } }; - }, []); + }, [getData]); return ( - + ); };