-
- {{ comment.contentExcerpt | removeHtml }}
+
+
+ {{ 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.spec.js b/webapp/components/notifications/NotificationList/NotificationList.spec.js
index 4972c09a1..82d3f5d62 100644
--- a/webapp/components/notifications/NotificationList/NotificationList.spec.js
+++ b/webapp/components/notifications/NotificationList/NotificationList.spec.js
@@ -40,9 +40,9 @@ describe('NotificationList.vue', () => {
propsData = {
notifications: [
{
- id: 'notification-41',
read: false,
- post: {
+ from: {
+ __typename: 'Post',
id: 'post-1',
title: 'some post title',
slug: 'some-post-title',
@@ -55,9 +55,9 @@ describe('NotificationList.vue', () => {
},
},
{
- id: 'notification-42',
read: false,
- post: {
+ from: {
+ __typename: 'Post',
id: 'post-2',
title: 'another post title',
slug: 'another-post-title',
@@ -115,9 +115,9 @@ describe('NotificationList.vue', () => {
.trigger('click')
})
- it("emits 'markAsRead' with the notificationId", () => {
+ it("emits 'markAsRead' with the id of the notification source", () => {
expect(wrapper.emitted('markAsRead')).toBeTruthy()
- expect(wrapper.emitted('markAsRead')[0]).toEqual(['notification-42'])
+ expect(wrapper.emitted('markAsRead')[0]).toEqual(['post-2'])
})
})
})
diff --git a/webapp/components/notifications/NotificationList/NotificationList.vue b/webapp/components/notifications/NotificationList/NotificationList.vue
index 43783ea56..d956f6129 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)"
/>