-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NV-3037] Fixed closing off the wrong socket in useUnreadCount.ts #4590
Conversation
Hey @Khongchai, |
@@ -66,7 +66,7 @@ export const useUnreadCount = ({ onSuccess, ...restOptions }: UseQueryOptions<IC | |||
); | |||
|
|||
return () => { | |||
socket.off(WebSocketEventEnum.UNSEEN); | |||
socket.off(WebSocketEventEnum.UNREAD); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in line 78 we would need to update to:
enabled: isSessionInitialized && fetchingStrategy.fetchUnreadCount
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I'll add this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@p-fernandez I've updated the condition. But I needed to add a couple of things more because the fetchingStrategy interface was missing the fetchUnreadCount key.
For the default value, I set it to true
so that existing code won't break (it was using unseen's default and it was true)
Hi, sorry for my late reply. The refetch key issue, as I have mentioned in this issue. I'm not quite sure if this really is a problem. I thought it was at first, but after having looked into it further, it was just making sure the unseen value is updated. I haven't checked Novu's code on this part, but should unseen be updated if unread is updated? I thought there was a bug, but after reading this comment, I'm not so sure For example, if something is marked as read should they also be marked automatically as seen? If so, the code is already working as intended (maybe some Novu backend logic to update all read fields as seen). If my understanding is incorrect and the refetch function was really not working as intended in some way, please let me know. |
3032773
to
0b5d9ee
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🌟
What change does this PR introduce?
This fixes an issue where the useUnreadCount hook closes the wrong websocket channel.
Why was this change needed?
#4582
Other information (Screenshots)