mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-18 11:49:19 +00:00
fix: unreadMessages not showing on notifications popover after refresh
This commit is contained in:
@@ -57,6 +57,8 @@ const NotificationsPopOver = () => {
|
||||
const [play] = useSound(alertSound);
|
||||
const soundAlertRef = useRef();
|
||||
|
||||
const historyRef = useRef(history);
|
||||
|
||||
useEffect(() => {
|
||||
soundAlertRef.current = play;
|
||||
|
||||
@@ -128,16 +130,16 @@ const NotificationsPopOver = () => {
|
||||
|
||||
if (shouldNotNotificate) return;
|
||||
|
||||
handleNotifications(data, history);
|
||||
handleNotifications(data);
|
||||
}
|
||||
});
|
||||
|
||||
return () => {
|
||||
socket.disconnect();
|
||||
};
|
||||
}, [history, user]);
|
||||
}, [user]);
|
||||
|
||||
const handleNotifications = (data, history) => {
|
||||
const handleNotifications = data => {
|
||||
const { message, contact, ticket } = data;
|
||||
|
||||
const options = {
|
||||
@@ -155,7 +157,7 @@ const NotificationsPopOver = () => {
|
||||
notification.onclick = e => {
|
||||
e.preventDefault();
|
||||
window.focus();
|
||||
history.push(`/tickets/${ticket.id}`);
|
||||
historyRef.current.push(`/tickets/${ticket.id}`);
|
||||
};
|
||||
|
||||
setDesktopNotifications(prevState => {
|
||||
|
||||
Reference in New Issue
Block a user