Skip to content

Commit d9a205b

Browse files
authored
Merge pull request #22 from gunet/fix/fetch-vc-notif
Fetch vc data on listen notification
2 parents 2256ab1 + c98bf75 commit d9a205b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/components/Notifications/HandlerNotification.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import React, { useState, useEffect, useCallback } from 'react';
1+
import React, { useState, useEffect, useCallback, useContext } from 'react';
22
import toast, { Toaster } from 'react-hot-toast';
33
import { onMessageListener } from '../../firebase';
44
import { AiOutlineClose } from 'react-icons/ai';
55
import logo from '../../assets/images/logo.png';
6+
import CredentialsContext from '../../context/CredentialsContext';
67

78
const ToastDisplay = ({ id, notification }) => {
89
return (
@@ -31,6 +32,7 @@ const ToastDisplay = ({ id, notification }) => {
3132

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

3537
const showToast = useCallback(
3638
() => toast((t) => <ToastDisplay id={t.id} notification={notification} />),
@@ -50,6 +52,7 @@ const HandlerNotification = () => {
5052
title: payload?.notification?.title,
5153
body: payload?.notification?.body,
5254
});
55+
getData();
5356
})
5457
.catch((err) => {
5558
console.log('Failed to receive message:', err);
@@ -60,10 +63,10 @@ const HandlerNotification = () => {
6063
messageListener();
6164
}
6265
};
63-
}, []);
66+
}, [getData]);
6467

6568
return (
66-
<Toaster />
69+
<Toaster />
6770
);
6871
};
6972

0 commit comments

Comments
 (0)