From 19042c4d91886b57967c87cd132dbb346843d0af Mon Sep 17 00:00:00 2001 From: Louis Chemineau Date: Tue, 15 Nov 2022 18:30:17 +0100 Subject: Fix mentions rendering in comment editor NcRichContentEditable needs an index of users to properly display them. This commit adds a caching logic and provides it to NcRichContentEditable. Signed-off-by: Louis Chemineau --- apps/comments/src/components/Comment.vue | 1 + apps/comments/src/views/Comments.vue | 39 ++++++++++++++++++-------------- 2 files changed, 23 insertions(+), 17 deletions(-) (limited to 'apps/comments') diff --git a/apps/comments/src/components/Comment.vue b/apps/comments/src/components/Comment.vue index 41284e50ca9..062dda74756 100644 --- a/apps/comments/src/components/Comment.vue +++ b/apps/comments/src/components/Comment.vue @@ -69,6 +69,7 @@ :auto-complete="autoComplete" :contenteditable="!loading" :value="localMessage" + :user-data="userData" @update:value="updateLocalMessage" @submit="onSubmit" /> } */ genMentionsData(mentions) { - const list = Object.values(mentions).flat() - return list.reduce((mentions, mention) => { - mentions[mention.mentionId] = { - // TODO: support groups - icon: 'icon-user', - id: mention.mentionId, - label: mention.mentionDisplayName, - source: 'users', - primary: getCurrentUser().uid === mention.mentionId, - } - return mentions - }, {}) + Object.values(mentions) + .flat() + .forEach(mention => { + this.userData[mention.mentionId] = { + // TODO: support groups + icon: 'icon-user', + id: mention.mentionId, + label: mention.mentionDisplayName, + source: 'users', + primary: getCurrentUser().uid === mention.mentionId, + } + }) + return this.userData }, /** @@ -251,7 +254,9 @@ export default { limit: loadState('comments', 'maxAutoCompleteResults'), }, }) - return callback(results.data.ocs.data) + // Save user data so it can be used by the editor to replace mentions + results.data.ocs.data.forEach(user => { this.userData[user.id] = user }) + return callback(Object.values(this.userData)) }, /** -- cgit v1.2.3