From af6d928dd6bd3414c72692cda4ba2d35edf4912c Mon Sep 17 00:00:00 2001 From: Marcus Eibrink-Lunzenauer <lunzenauer@elan-ev.de> Date: Tue, 13 Jun 2023 10:59:10 +0000 Subject: [PATCH] Fixes #2661. Closes #2661 Merge request studip/studip!1849 --- resources/vue/store/blubber.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/resources/vue/store/blubber.js b/resources/vue/store/blubber.js index bd1c8e107eb..c6730801f0d 100644 --- a/resources/vue/store/blubber.js +++ b/resources/vue/store/blubber.js @@ -213,6 +213,10 @@ export default { } }, + loadComment({ dispatch }, { id }) { + return dispatch('blubber-comments/loadById', { id }, { root: true }); + }, + async loadNewerComments({ commit, dispatch, getters, rootGetters }, { id, search }) { if (!getters.moreNewer(id)) { return; @@ -319,7 +323,7 @@ export default { { parent, relationship: 'blubber-default-thread', - data: { type: "blubber-threads", id }, + data: { type: 'blubber-threads', id }, }, { root: true } ); @@ -339,12 +343,16 @@ export default { updateState({ commit, dispatch }, datagram) { Object.entries(datagram).forEach(([method, data]) => { if (method === 'addNewComments') { - return Promise.all( - Object.keys(data).map((id) => { - commit('setMoreNewer', { id, hasMore: true }); - return dispatch('loadNewerComments', { id }); - }) - ); + const loadThreads = Object.keys(data).map((id) => { + commit('setMoreNewer', { id, hasMore: true }); + return dispatch('loadNewerComments', { id }); + }); + const loadComments = Object.values(data) + .flat() + .filter((comment) => comment.mkdate !== comment.chdate) + .map(({ comment_id }) => dispatch('loadComment', { id: comment_id })); + + return Promise.all(loadThreads.concat(loadComments)); } else if (method === 'removeDeletedComments') { return Promise.all( data.map((id) => { -- GitLab