|
25 | 25 | <!-- Editor --> |
26 | 26 | <Comment v-bind="editorData" |
27 | 27 | :auto-complete="autoComplete" |
| 28 | + :user-data="userData" |
28 | 29 | :editor="true" |
29 | 30 | :ressource-id="ressourceId" |
30 | 31 | class="comments__writer" |
@@ -77,9 +78,9 @@ import Vue from 'vue' |
77 | 78 |
|
78 | 79 | import EmptyContent from '@nextcloud/vue/dist/Components/EmptyContent' |
79 | 80 |
|
80 | | -import Comment from '../components/Comment' |
81 | | -import getComments, { DEFAULT_LIMIT } from '../services/GetComments' |
82 | | -import cancelableRequest from '../utils/cancelableRequest' |
| 81 | +import Comment from '../components/Comment.vue' |
| 82 | +import getComments, { DEFAULT_LIMIT } from '../services/GetComments.js' |
| 83 | +import cancelableRequest from '../utils/cancelableRequest.js' |
83 | 84 |
|
84 | 85 | Vue.use(VTooltip) |
85 | 86 |
|
@@ -111,6 +112,7 @@ export default { |
111 | 112 | }, |
112 | 113 |
|
113 | 114 | Comment, |
| 115 | + userData: {}, |
114 | 116 | } |
115 | 117 | }, |
116 | 118 |
|
@@ -153,21 +155,22 @@ export default { |
153 | 155 | /** |
154 | 156 | * Make sure we have all mentions as Array of objects |
155 | 157 | * @param {Array} mentions the mentions list |
156 | | - * @returns {Object[]} |
| 158 | + * @return {Object<string, object>} |
157 | 159 | */ |
158 | 160 | genMentionsData(mentions) { |
159 | | - const list = Object.values(mentions).flat() |
160 | | - return list.reduce((mentions, mention) => { |
161 | | - mentions[mention.mentionId] = { |
162 | | - // TODO: support groups |
163 | | - icon: 'icon-user', |
164 | | - id: mention.mentionId, |
165 | | - label: mention.mentionDisplayName, |
166 | | - source: 'users', |
167 | | - primary: getCurrentUser().uid === mention.mentionId, |
168 | | - } |
169 | | - return mentions |
170 | | - }, {}) |
| 161 | + Object.values(mentions) |
| 162 | + .flat() |
| 163 | + .forEach(mention => { |
| 164 | + this.userData[mention.mentionId] = { |
| 165 | + // TODO: support groups |
| 166 | + icon: 'icon-user', |
| 167 | + id: mention.mentionId, |
| 168 | + label: mention.mentionDisplayName, |
| 169 | + source: 'users', |
| 170 | + primary: getCurrentUser().uid === mention.mentionId, |
| 171 | + } |
| 172 | + }) |
| 173 | + return this.userData |
171 | 174 | }, |
172 | 175 |
|
173 | 176 | /** |
@@ -230,7 +233,9 @@ export default { |
230 | 233 | limit: loadState('comments', 'maxAutoCompleteResults'), |
231 | 234 | }, |
232 | 235 | }) |
233 | | - return callback(results.data.ocs.data) |
| 236 | + // Save user data so it can be used by the editor to replace mentions |
| 237 | + results.data.ocs.data.forEach(user => { this.userData[user.id] = user }) |
| 238 | + return callback(Object.values(this.userData)) |
234 | 239 | }, |
235 | 240 |
|
236 | 241 | /** |
|
0 commit comments