diff --git a/apps/app/hooks/use-issue-notification-subscription.tsx b/apps/app/hooks/use-issue-notification-subscription.tsx index 2abe353b0..a118bdf6a 100644 --- a/apps/app/hooks/use-issue-notification-subscription.tsx +++ b/apps/app/hooks/use-issue-notification-subscription.tsx @@ -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({ @@ -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({ diff --git a/apps/app/services/notifications.service.ts b/apps/app/services/notifications.service.ts index 412b03988..6c6bec62d 100644 --- a/apps/app/services/notifications.service.ts +++ b/apps/app/services/notifications.service.ts @@ -111,14 +111,10 @@ class UserNotificationsServices extends APIService { async subscribeToIssueNotifications( workspaceSlug: string, projectId: string, - issueId: string, - data: { - subscriber: string; - } + issueId: string ): Promise { 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) => {