N
Novu10mo ago
korayaggul

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.
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>
5 Replies
Pawan Jain
Pawan Jain10mo ago
@korayaggul could you please share the exact use case what you want to achieve? I am having a bit difficulty in understanding the exact need
korayaggul
korayaggulOP10mo ago
In general, I asked about unseen count and sending seen information when someone sees it, but very little can be done with socket, so I decided to use API ends, I solved my problem, thank you. @Pawan Jain
korayaggul
korayaggulOP10mo ago
@Pawan Jain I have another question, where can I send the id in the url?
const result = await novu.trigger("new-chat-messages", {
to: {
subscriberId: notificationUserProfile.user.id.toString(),
email: notificationUserProfile.user.email,
},
payload: {
data: {
id: response.data.attributes.chat.data.id,
creatorName: chatUserProfile.creator_profile.username,
},
},
const result = await novu.trigger("new-chat-messages", {
to: {
subscriberId: notificationUserProfile.user.id.toString(),
email: notificationUserProfile.user.email,
},
payload: {
data: {
id: response.data.attributes.chat.data.id,
creatorName: chatUserProfile.creator_profile.username,
},
},
No description
Pawan Jain
Pawan Jain10mo ago
change payload to
payload: {
id: response.data.attributes.chat.data.id,
creatorName: chatUserProfile.creator_profile.username,
},
payload: {
id: response.data.attributes.chat.data.id,
creatorName: chatUserProfile.creator_profile.username,
},
korayaggul
korayaggulOP10mo ago
thank you bro 🙏 @Pawan Jain
Want results from more Discord servers?
Add your server