notification subscription

This commit is contained in:
Ulf Gebhardt 2023-07-20 13:41:59 +02:00
parent 9e52ec5469
commit 1b8b356432
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9
4 changed files with 5 additions and 10 deletions

View File

@ -7,8 +7,8 @@ export default {
notificationAdded: { notificationAdded: {
subscribe: withFilter( subscribe: withFilter(
() => pubsub.asyncIterator(NOTIFICATION_ADDED), () => pubsub.asyncIterator(NOTIFICATION_ADDED),
(payload, variables) => { (payload, variables, context) => {
return payload.notificationAdded.to.id === variables.userId return payload.notificationAdded.to.id === context.user?.id
}, },
), ),
}, },

View File

@ -38,5 +38,5 @@ type Mutation {
} }
type Subscription { type Subscription {
notificationAdded(userId: ID!): NOTIFIED notificationAdded: NOTIFIED
} }

View File

@ -137,11 +137,6 @@ export default {
}, },
subscribeToMore: { subscribeToMore: {
document: notificationAdded(), document: notificationAdded(),
variables() {
return {
userId: this.user.id,
}
},
updateQuery: (previousResult, { subscriptionData }) => { updateQuery: (previousResult, { subscriptionData }) => {
const { const {
data: { notificationAdded: newNotification }, data: { notificationAdded: newNotification },

View File

@ -245,8 +245,8 @@ export const notificationAdded = () => {
${postFragment} ${postFragment}
${groupFragment} ${groupFragment}
subscription notifications($userId: ID!) { subscription notifications {
notificationAdded(userId: $userId) { notificationAdded {
id id
read read
reason reason