fix: notification subscribe endpoint (#1593)

* refactor: height of popover & api fetch call

* fix: notification subscribe endpoint
This commit is contained in:
Dakshesh Jain 2023-07-20 16:35:18 +05:30 committed by GitHub
parent 4aef8c2242
commit 51f10d5f36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 15 deletions

View File

@ -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({

View File

@ -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) => {