-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
feat(js): inbox support multiple counts for the provided filters #6159
Conversation
const filters = JSON.parse(value); | ||
if (Array.isArray(filters)) { | ||
return filters.map((el) => plainToClass(NotificationsFilter, el)); | ||
} |
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.
The filters are sent in the query params as the stringified JSON object. We need to parse it back from string to object and run the validation on its fields.
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.
The stringified JSON filters in counts creates a discrepancy between the count and the notifications endpoint where one filter is specified via separate query string parameters.
I don't have a good suggestion yet but I suggest we add a task to revise this post-release and opt-in for more alignment between the two endpoints.
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 one
} catch (error) { | ||
this._emitter.emit('feeds.fetch_count.error', { args, error }); | ||
throw error; | ||
} | ||
}); | ||
} | ||
|
||
async read(args: BaseArgs): Promise<Notification>; |
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.
It was missing
const response = await novu.feeds.fetchCount(payload); | ||
const count = response.data.count; | ||
onSuccess?.(count); | ||
const [unreadCount, { refetch }] = createResource( |
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.
this hook is not used but I had to update it's code
39bbf3c
to
b99ce01
Compare
const filters = JSON.parse(value); | ||
if (Array.isArray(filters)) { | ||
return filters.map((el) => plainToClass(NotificationsFilter, el)); | ||
} |
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.
The stringified JSON filters in counts creates a discrepancy between the count and the notifications endpoint where one filter is specified via separate query string parameters.
I don't have a good suggestion yet but I suggest we add a task to revise this post-release and opt-in for more alignment between the two endpoints.
apps/api/src/app/inbox/usecases/notifications-count/notifications-count.usecase.ts
Show resolved
Hide resolved
fe1cd2a
to
10d18ab
Compare
What changed? Why was the change needed?
In this PR:
GET /notifications/counts
endpoint which supports multiple filters in query params as JSON objectScreenshots
Expand for optional sections
Related enterprise PR
Special notes for your reviewer