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

fix: notification subscribe endpoint #1593

Merged
merged 4 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions apps/app/hooks/use-issue-notification-subscription.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,18 @@ const useUserIssueNotificationSubscription = (
const handleUnsubscribe = useCallback(() => {
if (!workspaceSlug || !projectId || !issueId) return;

mutate(
{
subscribed: false,
},
false
);

userNotificationServices
.unsubscribeFromIssueNotifications(
workspaceSlug as string,
projectId as string,
issueId as string
workspaceSlug.toString(),
projectId.toString(),
issueId.toString()
)
.then(() => {
mutate({
Expand All @@ -47,14 +54,18 @@ const useUserIssueNotificationSubscription = (
const handleSubscribe = useCallback(() => {
if (!workspaceSlug || !projectId || !issueId || !user) return;

mutate(
{
subscribed: true,
},
false
);

userNotificationServices
.subscribeToIssueNotifications(
workspaceSlug as string,
projectId as string,
issueId as string,
{
subscriber: user.id,
}
workspaceSlug.toString(),
projectId.toString(),
issueId.toString()
)
.then(() => {
mutate({
Expand Down
8 changes: 2 additions & 6 deletions apps/app/services/notifications.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,10 @@ class UserNotificationsServices extends APIService {
async subscribeToIssueNotifications(
workspaceSlug: string,
projectId: string,
issueId: string,
data: {
subscriber: string;
}
issueId: string
): Promise<any> {
return this.post(
`/api/workspaces/${workspaceSlug}/projects/${projectId}/issues/${issueId}/issue-subscribers/`,
data
`/api/workspaces/${workspaceSlug}/projects/${projectId}/issues/${issueId}/subscribe/`
)
.then((response) => response?.data)
.catch((error) => {
Expand Down