fix self-mention in comments

Signed-off-by: Hendrik Leidinger <hendrik.leidinger@gmx.de>
This commit is contained in:
Hendrik Leidinger 2025-10-18 20:47:43 -07:00
parent 9d5f803a98
commit 25051e5604

View file

@ -7,6 +7,7 @@ import { generateOcsUrl } from '@nextcloud/router'
import axios from '@nextcloud/axios'
import Config from '../services/config.tsx'
import { getNextcloudUrl } from '../helpers/url.js'
import { getCurrentUser } from '@nextcloud/auth'
export default {
methods: {
@ -24,6 +25,18 @@ export default {
}
}
// Workaround to add the current user to the suggestions if they are not already in the list
// https://github.com/nextcloud/server/issues/48180
const currentUser = getCurrentUser()
const userExists = users.some(user => user.id === currentUser.uid)
if (!userExists) {
const matchesSearch = currentUser.uid.toLowerCase().includes(text.toLowerCase()) || currentUser.displayName.toLowerCase().includes(text.toLowerCase())
if (matchesSearch) {
users.push({ id: currentUser.uid, label: currentUser.displayName })
}
}
const list = users.map((user) => {
const profile = window.location.protocol + '//' + getNextcloudUrl() + '/index.php/u/' + user.id
return {
@ -32,7 +45,6 @@ export default {
profile,
}
})
this.sendPostMessage('Action_Mention', { list })
}
if (type === 'selected') {