Socket Questions
Where can I get the unseencount information and how can I remove the message I saw from the unseencount?
It only appears here when there is a change. When the page is opened, it appears blank.
I'm pulling the data here and showing it, but I want to mark it as read when I click the button, how can I do that?
It only appears here when there is a change. When the page is opened, it appears blank.
useEffect(()=>{
if (socket) {
socket.on("unseen_count_changed", (data) => {
console.log("zxcdata22",data)
})
}
},[socket])useEffect(()=>{
if (socket) {
socket.on("unseen_count_changed", (data) => {
console.log("zxcdata22",data)
})
}
},[socket])I'm pulling the data here and showing it, but I want to mark it as read when I click the button, how can I do that?
useEffect(() => {
if (socket) {
socket.on("notification_received", (data) => {
setNotificationContent(data.message.content);
setNotificationContentCreator(data.message.payload.data.creatorName);
setNotificationContentUrl(data.message.payload.data.url);
setOpenNotification(true);
});
}
return () => {
// if (socket) {
// socket.off("notification_received");
// }
};
}, [socket]);
<Link
to={notificationContentUrl}
style={{
position: "absolute",
zIndex: 999,
right: 10,
textDecoration:'none'
}}
>
<Notification icon={checkIcon} withCloseButton={false} color="teal" title="All good!" mt="md">
{notificationContent + " " + notificationContentCreator}
</Notification>
</Link> useEffect(() => {
if (socket) {
socket.on("notification_received", (data) => {
setNotificationContent(data.message.content);
setNotificationContentCreator(data.message.payload.data.creatorName);
setNotificationContentUrl(data.message.payload.data.url);
setOpenNotification(true);
});
}
return () => {
// if (socket) {
// socket.off("notification_received");
// }
};
}, [socket]);
<Link
to={notificationContentUrl}
style={{
position: "absolute",
zIndex: 999,
right: 10,
textDecoration:'none'
}}
>
<Notification icon={checkIcon} withCloseButton={false} color="teal" title="All good!" mt="md">
{notificationContent + " " + notificationContentCreator}
</Notification>
</Link>