N
Novu2w ago
wasabi

Q: Is it possible to get unread count (total and per tab)?

I have this application using the @novu/react. Is it possible to get the total unread count for each tab (and total between all)?
4 Replies
wasabi
wasabiOP2w ago
Hello, @Pawan Jain , while I still experiment the behavior mentioned on that post, no, this is a separated post.
Pawan Jain
Pawan Jain4d ago
@wasabi You can use useCounts hook multiple times with required filters An example 👇🏻
const { counts: unreadCountForTab1, refetch: refetchUnreadCountForTab1 } =
useCounts({
filters: [{ read: false, tags: ["tab1"] }],
});

const { counts: unreadCountForTab2, refetch: refetchUnreadCountForTab2 } =
useCounts({
filters: [{ read: false, tags: ["tab2"] }],
});

const { counts: totalUnreadCount, refetch: refetchTotalUnreadCount } =
useCounts({
filters: [{ read: false }],
});
const { counts: unreadCountForTab1, refetch: refetchUnreadCountForTab1 } =
useCounts({
filters: [{ read: false, tags: ["tab1"] }],
});

const { counts: unreadCountForTab2, refetch: refetchUnreadCountForTab2 } =
useCounts({
filters: [{ read: false, tags: ["tab2"] }],
});

const { counts: totalUnreadCount, refetch: refetchTotalUnreadCount } =
useCounts({
filters: [{ read: false }],
});
Let me know if you are facing any issue @wasabi ping
wasabi
wasabiOP2d ago
Hello, sorry for late reply, normally i don't have discord notifications turned on, but i have turned them on now. I don't seem to be able to use the useCount when passing tags to the filters array. Take a look: https://codesandbox.io/p/devbox/novu-no-tabs-forked-js33ll?workspaceId=ws_7SUJy9312Hx95pVV2BTHfM @Pawan Jain

Did you find this page helpful?