Skip to content
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

Merged
merged 4 commits into from
Jul 30, 2024

Conversation

LetItRock
Copy link
Contributor

What changed? Why was the change needed?

In this PR:

  • API changes in the GET /notifications/counts endpoint which supports multiple filters in query params as JSON object
  • JS SDK changes that reflect the API functionality with better interface

Screenshots

Expand for optional sections

Related enterprise PR

Special notes for your reviewer

Copy link

linear bot commented Jul 25, 2024

Comment on lines +25 to +28
const filters = JSON.parse(value);
if (Array.isArray(filters)) {
return filters.map((el) => plainToClass(NotificationsFilter, el));
}
Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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>;
Copy link
Contributor Author

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(
Copy link
Contributor Author

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

Comment on lines +25 to +28
const filters = JSON.parse(value);
if (Array.isArray(filters)) {
return filters.map((el) => plainToClass(NotificationsFilter, el));
}
Copy link
Contributor

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.

packages/js/src/feeds/feeds.ts Show resolved Hide resolved
packages/js/src/ui/api/hooks/useFetchUnreadCount.ts Outdated Show resolved Hide resolved
LetItRock added a commit that referenced this pull request Jul 30, 2024
@LetItRock LetItRock force-pushed the com-104-inbox-counts-for-multiple-filters branch from fe1cd2a to 10d18ab Compare July 30, 2024 10:52
@LetItRock LetItRock merged commit 160de45 into next Jul 30, 2024
23 checks passed
@LetItRock LetItRock deleted the com-104-inbox-counts-for-multiple-filters branch July 30, 2024 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants