diff --git a/webapp/components/Notification/Notification.spec.js b/webapp/components/Notification/Notification.spec.js
index 36e0e8d9d..1ac25d4a5 100644
--- a/webapp/components/Notification/Notification.spec.js
+++ b/webapp/components/Notification/Notification.spec.js
@@ -205,20 +205,16 @@ describe('Notification', () => {
propsData.notification = {
reason: 'filed_report_on_resource',
from: {
- __typename: 'Report',
- id: 'reportOnUser',
- filed: [
- {
- reasonCategory: 'discrimination_etc',
- reasonDescription: 'This user is harassing me with bigoted remarks!',
- reportedResource: {
- __typename: 'User',
- id: 'badWomen',
- slug: 'mrs.-badwomen',
- name: 'Mrs. Badwomen',
- },
- },
- ],
+ __typename: 'FiledReport',
+ reportId: 'reportOnUser',
+ reasonCategory: 'discrimination_etc',
+ reasonDescription: 'This user is harassing me with bigoted remarks!',
+ resource: {
+ __typename: 'User',
+ id: 'badWomen',
+ slug: 'mrs.-badwomen',
+ name: 'Mrs. Badwomen',
+ },
},
}
})
diff --git a/webapp/components/Notification/Notification.vue b/webapp/components/Notification/Notification.vue
index 121965a0f..4fb6564e2 100644
--- a/webapp/components/Notification/Notification.vue
+++ b/webapp/components/Notification/Notification.vue
@@ -73,7 +73,7 @@
-
+
{
wrapper = Wrapper()
})
- describe('click on a notification', () => {
+ describe("emit 'read', like as clicked on a notification", () => {
beforeEach(() => {
- wrapper.find('.notification .notifications-card').trigger('click')
+ wrapper.find(Notification).vm.$emit('read')
})
- it("emits 'markAsRead' with the id of the notification source", () => {
+ it("emits 'markAsRead' with the id of the notification source, if 'read' was emited", () => {
expect(wrapper.emitted('markAsRead')[0]).toEqual(['post-1'])
})
})
diff --git a/webapp/components/NotificationList/NotificationList.vue b/webapp/components/NotificationList/NotificationList.vue
index fd2d6366c..5cd5f1bce 100644
--- a/webapp/components/NotificationList/NotificationList.vue
+++ b/webapp/components/NotificationList/NotificationList.vue
@@ -4,7 +4,7 @@
v-for="notification in notifications"
:key="notification.id"
:notification="notification"
- @read="markAsRead(notification.from.id)"
+ @read="markAsRead(notification.from.id || notification.from.reportId)"
/>
diff --git a/webapp/components/NotificationsTable/NotificationsTable.spec.js b/webapp/components/NotificationsTable/NotificationsTable.spec.js
index d42c0126d..2234d2c8d 100644
--- a/webapp/components/NotificationsTable/NotificationsTable.spec.js
+++ b/webapp/components/NotificationsTable/NotificationsTable.spec.js
@@ -167,7 +167,7 @@ describe('NotificationsTable.vue', () => {
it('renders a link to the user', () => {
const userLink = thirdRowNotification.find('[data-test="notification-title-link"]')
- expect(userLink.text()).toEqual(reportNotification.from.filed[0].reportedResource.name)
+ expect(userLink.text()).toEqual(reportNotification.from.resource.name)
})
it('renders the reported users slug', () => {
@@ -183,7 +183,7 @@ describe('NotificationsTable.vue', () => {
it('renders the reported category', () => {
wrapper = Wrapper()
expect(wrapper.text()).toContain(
- 'report.reason.category.options.' + reportNotification.from.filed[0].reasonCategory,
+ 'report.reason.category.options.' + reportNotification.from.reasonCategory,
)
})
@@ -194,7 +194,7 @@ describe('NotificationsTable.vue', () => {
it('renders the reported description', () => {
wrapper = Wrapper()
- expect(wrapper.text()).toContain(reportNotification.from.filed[0].reasonDescription)
+ expect(wrapper.text()).toContain(reportNotification.from.reasonDescription)
})
})
diff --git a/webapp/components/utils/Notifications.js b/webapp/components/utils/Notifications.js
index b60fbf5de..d6ddd9fde 100644
--- a/webapp/components/utils/Notifications.js
+++ b/webapp/components/utils/Notifications.js
@@ -44,26 +44,23 @@ export const testNotifications = [
read: false,
reason: 'filed_report_on_resource',
from: {
- __typename: 'Report',
- id: 'reportOnUser',
- filed: [
- {
- reasonCategory: 'discrimination_etc',
- reasonDescription: 'This user is harassing me with bigoted remarks!',
- reportedResource: {
- __typename: 'User',
- id: 'badWomen',
- slug: 'mrs.-badwomen',
- name: 'Mrs. Badwomen',
- },
- },
- ],
+ __typename: 'FiledReport',
+ reportId: 'reportOnUser',
+ reasonCategory: 'discrimination_etc',
+ reasonDescription: 'This user is harassing me with bigoted remarks!',
+ resource: {
+ __typename: 'User',
+ id: 'badWomen',
+ slug: 'mrs.-badwomen',
+ name: 'Mrs. Badwomen',
+ },
},
},
]
export const extractNotificationDataOfCurrentUser = (notification, currentUser) => {
const from = notification.from // for readability
+ // Wolle console.log('from: ', from)
let user = null
let post = null
let comment = null
@@ -78,7 +75,7 @@ export const extractNotificationDataOfCurrentUser = (notification, currentUser)
// extract data out of the deep structure of db response
- // leave undefined data as default, see above, so later by priority user, comment, post we get easely a clou what it is
+ // leave undefined data as default, see above. so later by priority user, comment, post we get easely a clou what it is
switch (from.__typename) {
case 'Comment':
comment = from
@@ -95,35 +92,32 @@ export const extractNotificationDataOfCurrentUser = (notification, currentUser)
iconTooltip = 'notifications.post'
triggerer = post.author
break
- case 'Report':
- {
- const filed = from.filed[0] // for readability
- report = {
- reasonCategory: filed.reasonCategory,
- reasonDescription: filed.reasonDescription,
- }
- isReport = true
- iconName = 'balance-scale'
- iconTooltip = 'notifications.report.name'
- triggerer = currentUser
- switch (filed.reportedResource.__typename) {
- case 'User':
- user = filed.reportedResource
- isUser = true
- reasonTranslationExtention = '.user'
- break
- case 'Comment':
- comment = filed.reportedResource
- post = filed.reportedResource.post
- isComment = true
- reasonTranslationExtention = '.comment'
- break
- case 'Post':
- post = filed.reportedResource
- isPost = true
- reasonTranslationExtention = '.post'
- break
- }
+ case 'FiledReport':
+ report = {
+ reasonCategory: from.reasonCategory,
+ reasonDescription: from.reasonDescription,
+ }
+ isReport = true
+ iconName = 'balance-scale'
+ iconTooltip = 'notifications.report.name'
+ triggerer = currentUser
+ switch (from.resource.__typename) {
+ case 'User':
+ user = from.resource
+ isUser = true
+ reasonTranslationExtention = '.user'
+ break
+ case 'Comment':
+ comment = from.resource
+ post = from.resource.post
+ isComment = true
+ reasonTranslationExtention = '.comment'
+ break
+ case 'Post':
+ post = from.resource
+ isPost = true
+ reasonTranslationExtention = '.post'
+ break
}
break
}
diff --git a/webapp/graphql/User.js b/webapp/graphql/User.js
index e557f98e6..034723bfe 100644
--- a/webapp/graphql/User.js
+++ b/webapp/graphql/User.js
@@ -93,35 +93,33 @@ export const notificationQuery = i18n => {
}
}
}
- ... on Report {
- id
- filed {
- reasonCategory
- reasonDescription
- reportedResource {
- __typename
- ... on User {
+ ... on FiledReport {
+ reportId
+ reasonCategory
+ reasonDescription
+ resource {
+ __typename
+ ... on User {
+ ...user
+ ...userCounts
+ }
+ ... on Post {
+ ...post
+ author {
...user
- ...userCounts
}
- ... on Post {
+ }
+ ... on Comment {
+ ...comment
+ author {
+ ...user
+ }
+ post {
...post
author {
...user
}
}
- ... on Comment {
- ...comment
- author {
- ...user
- }
- post {
- ...post
- author {
- ...user
- }
- }
- }
}
}
}