forked from Ivasoft/mattermost-mobile
MM-52888 Always load users mentioned in message attachments (#7361)
This commit is contained in:
@@ -7,9 +7,13 @@ import {MENTIONS_REGEX} from '@constants/autocomplete';
|
||||
export const getNeededAtMentionedUsernames = (usernames: Set<string>, posts: Post[], excludeUsername?: string) => {
|
||||
const usernamesToLoad = new Set<string>();
|
||||
|
||||
posts.forEach((p) => {
|
||||
const findNeededUsernames = (text?: string) => {
|
||||
if (!text || !text.includes('@')) {
|
||||
return;
|
||||
}
|
||||
|
||||
let match;
|
||||
while ((match = MENTIONS_REGEX.exec(p.message)) !== null) {
|
||||
while ((match = MENTIONS_REGEX.exec(text)) !== null) {
|
||||
const lowercaseMatch = match[1].toLowerCase();
|
||||
|
||||
if (General.SPECIAL_MENTIONS.has(lowercaseMatch)) {
|
||||
@@ -26,7 +30,19 @@ export const getNeededAtMentionedUsernames = (usernames: Set<string>, posts: Pos
|
||||
|
||||
usernamesToLoad.add(lowercaseMatch);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
for (const post of posts) {
|
||||
// These correspond to the fields searched by getMentionsEnabledFields on the server
|
||||
findNeededUsernames(post.message);
|
||||
|
||||
if (post.props?.attachments) {
|
||||
for (const attachment of post.props.attachments) {
|
||||
findNeededUsernames(attachment.pretext);
|
||||
findNeededUsernames(attachment.text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return usernamesToLoad;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user