From c585b23d7a587b43ad182c46f5222529b10240d1 Mon Sep 17 00:00:00 2001 From: roschaefer Date: Fri, 30 Aug 2019 01:24:15 +0200 Subject: [PATCH] Fix notification queries in webapp --- .../Notification/Notification.vue | 35 ++--- .../NotificationList/NotificationList.vue | 6 +- .../NotificationMenu/NotificationMenu.vue | 39 ++--- webapp/graphql/User.js | 135 ++++++++++-------- webapp/plugins/apollo-config.js | 8 ++ .../plugins/apollo-config/fragmentTypes.json | 18 +++ webapp/store/auth.js | 17 --- webapp/store/notifications.js | 99 ------------- 8 files changed, 138 insertions(+), 219 deletions(-) create mode 100644 webapp/plugins/apollo-config/fragmentTypes.json delete mode 100644 webapp/store/notifications.js diff --git a/webapp/components/notifications/Notification/Notification.vue b/webapp/components/notifications/Notification/Notification.vue index 193b5f67b..31b61be40 100644 --- a/webapp/components/notifications/Notification/Notification.vue +++ b/webapp/components/notifications/Notification/Notification.vue @@ -2,13 +2,7 @@ - - + {{ $t(`notifications.menu.${notification.reason}`) }} @@ -22,16 +16,15 @@ > -
{{ post.contentExcerpt | removeHtml }}
-
- Comment: - {{ comment.contentExcerpt | removeHtml }} +
+ Comment: + {{ from.contentExcerpt | removeHtml }}
@@ -54,23 +47,21 @@ export default { }, }, computed: { - resourceType() { - return this.post.id ? 'Post' : 'Comment' + from() { + return this.notification.from }, - post() { - return this.notification.post || {} - }, - comment() { - return this.notification.comment || {} + isComment() { + return this.from.__typename === 'Comment' }, params() { + const post = this.isComment ? this.from.post : this.from return { - id: this.post.id || this.comment.post.id, - slug: this.post.slug || this.comment.post.slug, + id: post.id, + slug: post.slug, } }, hashParam() { - return this.post.id ? {} : { hash: `#commentId-${this.comment.id}` } + return this.isComment ? { hash: `#commentId-${this.from.id}` } : {} }, }, } diff --git a/webapp/components/notifications/NotificationList/NotificationList.vue b/webapp/components/notifications/NotificationList/NotificationList.vue index 43783ea56..aac040785 100644 --- a/webapp/components/notifications/NotificationList/NotificationList.vue +++ b/webapp/components/notifications/NotificationList/NotificationList.vue @@ -4,7 +4,7 @@ v-for="notification in notifications" :key="notification.id" :notification="notification" - @read="markAsRead(notification.id)" + @read="markAsRead(notification.from.id)" />
@@ -24,8 +24,8 @@ export default { }, }, methods: { - markAsRead(notificationId) { - this.$emit('markAsRead', notificationId) + async markAsRead(notificationSourceId) { + this.$emit('markAsRead', notificationSourceId) }, }, } diff --git a/webapp/components/notifications/NotificationMenu/NotificationMenu.vue b/webapp/components/notifications/NotificationMenu/NotificationMenu.vue index c534f2986..8dc496efc 100644 --- a/webapp/components/notifications/NotificationMenu/NotificationMenu.vue +++ b/webapp/components/notifications/NotificationMenu/NotificationMenu.vue @@ -18,7 +18,7 @@