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) + }, }, }