From 1b8b356432e753ba0919f63bd7629f1c5adabd97 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 20 Jul 2023 13:41:59 +0200 Subject: [PATCH] notification subscription --- backend/src/schema/resolvers/notifications.ts | 4 ++-- backend/src/schema/types/type/NOTIFIED.gql | 2 +- webapp/components/NotificationMenu/NotificationMenu.vue | 5 ----- webapp/graphql/User.js | 4 ++-- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/backend/src/schema/resolvers/notifications.ts b/backend/src/schema/resolvers/notifications.ts index e427de227..6a3e232cc 100644 --- a/backend/src/schema/resolvers/notifications.ts +++ b/backend/src/schema/resolvers/notifications.ts @@ -7,8 +7,8 @@ export default { notificationAdded: { subscribe: withFilter( () => pubsub.asyncIterator(NOTIFICATION_ADDED), - (payload, variables) => { - return payload.notificationAdded.to.id === variables.userId + (payload, variables, context) => { + return payload.notificationAdded.to.id === context.user?.id }, ), }, diff --git a/backend/src/schema/types/type/NOTIFIED.gql b/backend/src/schema/types/type/NOTIFIED.gql index 62a1f3696..1f825decc 100644 --- a/backend/src/schema/types/type/NOTIFIED.gql +++ b/backend/src/schema/types/type/NOTIFIED.gql @@ -38,5 +38,5 @@ type Mutation { } type Subscription { - notificationAdded(userId: ID!): NOTIFIED + notificationAdded: NOTIFIED } diff --git a/webapp/components/NotificationMenu/NotificationMenu.vue b/webapp/components/NotificationMenu/NotificationMenu.vue index 9e94e07d7..d0e21bf96 100644 --- a/webapp/components/NotificationMenu/NotificationMenu.vue +++ b/webapp/components/NotificationMenu/NotificationMenu.vue @@ -137,11 +137,6 @@ export default { }, subscribeToMore: { document: notificationAdded(), - variables() { - return { - userId: this.user.id, - } - }, updateQuery: (previousResult, { subscriptionData }) => { const { data: { notificationAdded: newNotification }, diff --git a/webapp/graphql/User.js b/webapp/graphql/User.js index fcdac0989..4b743a0e3 100644 --- a/webapp/graphql/User.js +++ b/webapp/graphql/User.js @@ -245,8 +245,8 @@ export const notificationAdded = () => { ${postFragment} ${groupFragment} - subscription notifications($userId: ID!) { - notificationAdded(userId: $userId) { + subscription notifications { + notificationAdded { id read reason