novuhq / novu

Open-Source Notification Platform. Embeddable Notification Center, E-mail, Push and Slack Integrations.
https://novu.co
Other
34.72k stars 3.56k forks source link

πŸ› Bug Report: Headless API issue over removing and refetching queries. #5011

Closed vichustephen closed 9 months ago

vichustephen commented 10 months ago

πŸ“œ Description

In headless API we use a set of events like markAs, listenNotificationReceive, deleteNotification, deleteNotifications,etc. While we use these methods to integrate our custom component with novu we have found some issues. When we make changes to notifications it should refetch the queries at certain events and remove them for certain events.

  1. When a single notification is deleted , the queries to refetch the notifications are removed.
  2. When we receive a new notification , the queries are removed.
  3. When all notifications are removed . the queries are refetched.

There are few more i'll update it below.

Though all of these events works perfectly in Notification Center Component.

πŸ‘Ÿ Reproduction steps

Implement the headless API with infinite scrolling and implement the above mentioned methods so you can observe the behaviour. Compare with Novu Notification Center component. In there these methods are implemented perfectly.

πŸ‘ Expected behavior

  1. When a single notification is deleted , the queries must be refetched.
  2. When we receive a new notification , the queries must be refetched.
  3. When all notifications are removed . the queries must be removed.
  4. When unseenCount changed , the queries must not be removed.
  5. When unreadCount changed, the queries must not be removed.

πŸ‘Ž Actual Behavior with Screenshots

  1. Here I have a screenshot of API calls in debugger. I have used markAs method so it refetched the queries and its correct.

image

  1. Now here I have deleted a single notification and it has not refetched any queries and instead removed them. Hence even the next subsequent calls are not happening. Like when I call the markAs method, it is not refetching since the queries are already removed.

image

Ok now here I will post the code comparision screenshots between Notification Center Component and Headless API.

  1. Here is code for delete single notification in Notification Center Component: image

Here is the code on Headless API:

image

  1. Here is the code for unseenCount change in Notification Center Component:

image

Here is the code on Headless API: image

Novu version

0.21.0

npm version

No response

node version

No response

πŸ“ƒ Provide any additional context for the Bug.

No response

πŸ‘€ Have you spent some time to check if this bug has been raised before?

🏒 Have you read the Contributing Guidelines?

Are you willing to submit PR?

Yes I am willing to submit a PR!

linear[bot] commented 10 months ago

NV-3319 πŸ› Bug Report: Headless API issue over removing and refetching queries.

vichustephen commented 9 months ago

Hi @scopsy , @jainpawan21 , I have raised raised PR for this issue : https://github.com/novuhq/novu/pull/5021