From 73cc068469f0f2b61338b6b6d9547b80e633b6a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Thu, 19 Sep 2019 09:55:31 +0200 Subject: [PATCH 01/31] Fix lost translation --- .../Notification/Notification.spec.js | 14 +++++++------- .../notifications/Notification/Notification.vue | 6 ++++-- webapp/locales/de.json | 5 +++-- webapp/locales/en.json | 5 +++-- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/webapp/components/notifications/Notification/Notification.spec.js b/webapp/components/notifications/Notification/Notification.spec.js index 9ca47e7a0..54e6b4ab3 100644 --- a/webapp/components/notifications/Notification/Notification.spec.js +++ b/webapp/components/notifications/Notification/Notification.spec.js @@ -69,16 +69,16 @@ describe('Notification', () => { it('renders reason', () => { wrapper = Wrapper() expect(wrapper.find('.reason-text-for-test').text()).toEqual( - 'notifications.menu.commented_on_post', + 'notifications.reason.commented_on_post', ) }) it('renders title', () => { wrapper = Wrapper() expect(wrapper.text()).toContain("It's a post title") }) - it('renders the "Comment:"', () => { + it('renders the identifier "notifications.comment"', () => { wrapper = Wrapper() - expect(wrapper.text()).toContain('Comment:') + expect(wrapper.text()).toContain('notifications.comment') }) it('renders the contentExcerpt', () => { wrapper = Wrapper() @@ -119,7 +119,7 @@ describe('Notification', () => { it('renders reason', () => { wrapper = Wrapper() expect(wrapper.find('.reason-text-for-test').text()).toEqual( - 'notifications.menu.mentioned_in_post', + 'notifications.reason.mentioned_in_post', ) }) it('renders title', () => { @@ -169,7 +169,7 @@ describe('Notification', () => { it('renders reason', () => { wrapper = Wrapper() expect(wrapper.find('.reason-text-for-test').text()).toEqual( - 'notifications.menu.mentioned_in_comment', + 'notifications.reason.mentioned_in_comment', ) }) it('renders title', () => { @@ -177,9 +177,9 @@ describe('Notification', () => { expect(wrapper.text()).toContain("It's a post title") }) - it('renders the "Comment:"', () => { + it('renders the identifier "notifications.comment"', () => { wrapper = Wrapper() - expect(wrapper.text()).toContain('Comment:') + expect(wrapper.text()).toContain('notifications.comment') }) it('renders the contentExcerpt', () => { diff --git a/webapp/components/notifications/Notification/Notification.vue b/webapp/components/notifications/Notification/Notification.vue index 93ca42980..dc9383c85 100644 --- a/webapp/components/notifications/Notification/Notification.vue +++ b/webapp/components/notifications/Notification/Notification.vue @@ -5,7 +5,7 @@ - {{ $t(`notifications.menu.${notification.reason}`) }} + {{ $t(`notifications.reason.${notification.reason}`) }} @@ -23,7 +23,9 @@ >
- Comment: + + {{ $t(`notifications.comment`) }}: + {{ from.contentExcerpt | removeHtml }}
diff --git a/webapp/locales/de.json b/webapp/locales/de.json index fa9d66860..7b7bc3ec1 100644 --- a/webapp/locales/de.json +++ b/webapp/locales/de.json @@ -135,11 +135,12 @@ } }, "notifications": { - "menu": { + "reason": { "mentioned_in_post": "Hat dich in einem Beitrag erwähnt …", "mentioned_in_comment": "Hat dich in einem Kommentar erwähnt …", "commented_on_post": "Hat deinen Beitrag kommentiert …" - } + }, + "comment": "Kommentar" }, "search": { "placeholder": "Suchen", diff --git a/webapp/locales/en.json b/webapp/locales/en.json index 592fc57e4..8204d4741 100644 --- a/webapp/locales/en.json +++ b/webapp/locales/en.json @@ -136,11 +136,12 @@ } }, "notifications": { - "menu": { + "reason": { "mentioned_in_post": "Mentioned you in a post …", "mentioned_in_comment": "Mentioned you in a comment …", "commented_on_post": "Commented on your post …" - } + }, + "comment": "Comment" }, "search": { "placeholder": "Search", From f968c12ccfa2c9c0b530e92fb62289da5b3d9f77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Thu, 19 Sep 2019 15:33:35 +0200 Subject: [PATCH 02/31] Implement updating by time and add new ones to the list --- .../NotificationMenu/NotificationMenu.vue | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/webapp/components/notifications/NotificationMenu/NotificationMenu.vue b/webapp/components/notifications/NotificationMenu/NotificationMenu.vue index 51b90089f..af52d8395 100644 --- a/webapp/components/notifications/NotificationMenu/NotificationMenu.vue +++ b/webapp/components/notifications/NotificationMenu/NotificationMenu.vue @@ -35,7 +35,39 @@ export default { props: { placement: { type: String }, }, + created() { + setInterval(this.updateNotifications, 10000) + }, + destroyed() { + clearInterval(this.updateNotifications) + }, methods: { + async updateNotifications() { + try { + const { + data: { notifications }, + } = await this.$apollo.mutate({ + mutation: notificationQuery(this.$i18n), + }) + // add all the new notifications to the notifications + if (notifications) { + notifications.forEach(updatedElement => { + const sameNotification = this.notifications.find(function(oldElement) { + return ( + oldElement.from.id === updatedElement.from.id && + oldElement.createdAt === updatedElement.createdAt && + oldElement.reason === updatedElement.reason + ) + }) + if (sameNotification === undefined) { + this.notifications.unshift(updatedElement) + } + }) + } + } catch (err) { + throw new Error(err) + } + }, async markAsRead(notificationSourceId) { const variables = { id: notificationSourceId } try { From ca8bb9e43448d8a4ea6b66a43c080787c72c052b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Fri, 20 Sep 2019 09:19:35 +0200 Subject: [PATCH 03/31] Added timing as constant --- .../notifications/NotificationMenu/NotificationMenu.vue | 3 ++- webapp/constants/notifications.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 webapp/constants/notifications.js diff --git a/webapp/components/notifications/NotificationMenu/NotificationMenu.vue b/webapp/components/notifications/NotificationMenu/NotificationMenu.vue index af52d8395..1bff000ed 100644 --- a/webapp/components/notifications/NotificationMenu/NotificationMenu.vue +++ b/webapp/components/notifications/NotificationMenu/NotificationMenu.vue @@ -18,6 +18,7 @@