From f4465a9b660201bc654815ca50037a4b27268101 Mon Sep 17 00:00:00 2001 From: Vitor Mattos Date: Sun, 16 Jul 2023 16:21:03 -0300 Subject: [PATCH] List Notifications Signed-off-by: Vitor Mattos --- src/store/index.js | 5 ++++- src/views/Notifications.vue | 31 +++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/store/index.js b/src/store/index.js index 84a1269..e7e30e2 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -3,6 +3,9 @@ import Vuex, { Store } from 'vuex' import storeConfig from './storeConfig.js' +// eslint-disable-next-line n/no-missing-import, import/no-unresolved +import announcementsStore from 'apps/announcementcenter/src/store/announcementsStore.js' + Vue.use(Vuex) -export default new Store(storeConfig) +export default new Store({...storeConfig, ...announcementsStore}) diff --git a/src/views/Notifications.vue b/src/views/Notifications.vue index e5530c2..a82cb80 100644 --- a/src/views/Notifications.vue +++ b/src/views/Notifications.vue @@ -63,6 +63,37 @@ export default { this.$store.dispatch('addAnnouncement', announcement) }) }, + + /** + * Load the comments of the announcements + * + * @param {number} id the announcement + */ + async onClickAnnouncement(id) { + if (id === this.activeId) { + return + } + + this.activeId = id + + if (!this.activateAnnouncementHasComments) { + return + } + + if (id === 0) { + // Destroy the comments view as the sidebar is destroyed + this.commentsView = null + return + } + + if (!this.commentsView) { + // Create a new comments view when there is none + this.commentsView = new OCA.Comments.View('announcement') + } + + await this.commentsView.update(id) + this.commentsView.$mount(this.$refs.sidebar) + }, }, }