FIX: Do not add mentioned groups as mentioned users (#21867)
When a user type a message with mentions, the autocomplete popup may suggest users or groups. We were adding all these object to the `currentMessage.mentionedUsers` collection, while we should have been adding only users. A group added to that collection led to the error later when trying to update user status on mentions.
This commit is contained in:
parent
89b18b21ec
commit
bb21476f68
|
@ -415,6 +415,11 @@ export default class ChatComposer extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
#addMentionedUser(userData) {
|
||||
const user = User.create(userData);
|
||||
this.currentMessage.mentionedUsers.set(user.id, user);
|
||||
}
|
||||
|
||||
#applyUserAutocomplete($textarea) {
|
||||
if (!this.siteSettings.enable_mentions) {
|
||||
return;
|
||||
|
@ -426,10 +431,12 @@ export default class ChatComposer extends Component {
|
|||
width: "100%",
|
||||
treatAsTextarea: true,
|
||||
autoSelectFirstSuggestion: true,
|
||||
transformComplete: (userData) => {
|
||||
const user = User.create(userData);
|
||||
this.currentMessage.mentionedUsers.set(user.id, user);
|
||||
return user.username || user.name;
|
||||
transformComplete: (obj) => {
|
||||
if (obj.isUser) {
|
||||
this.#addMentionedUser(obj);
|
||||
}
|
||||
|
||||
return obj.username || obj.name;
|
||||
},
|
||||
dataSource: (term) => {
|
||||
return userSearch({ term, includeGroups: true }).then((result) => {
|
||||
|
|
Loading…
Reference in New Issue