Fix recent mentions
This commit is contained in:
parent
d2e2cf3ec1
commit
eb10f92875
3 changed files with 16 additions and 19 deletions
|
|
@ -577,17 +577,12 @@ export const fetchPostAuthors = async (serverUrl: string, posts: Post[], fetchOn
|
|||
|
||||
const usernamesToLoad = getNeededAtMentionedUsernames(existingUserNames, posts, excludeUsername);
|
||||
const userIdsToLoad = new Set<string>();
|
||||
posts.forEach((p) => {
|
||||
const userId = p.user_id;
|
||||
|
||||
if (userId === currentUserId) {
|
||||
return;
|
||||
for (const p of posts) {
|
||||
const {user_id} = p;
|
||||
if (user_id !== currentUserId) {
|
||||
userIdsToLoad.add(user_id);
|
||||
}
|
||||
|
||||
if (!existingUserIds.has(userId)) {
|
||||
userIdsToLoad.add(userId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
const promises: Array<Promise<UserProfile[]>> = [];
|
||||
|
|
|
|||
|
|
@ -45,16 +45,15 @@ export async function fetchRecentMentions(serverUrl: string): Promise<PostSearch
|
|||
throw results.error;
|
||||
}
|
||||
|
||||
const promises: Array<Promise<Model[]>> = [];
|
||||
const mentions: IdValue = {
|
||||
id: SYSTEM_IDENTIFIERS.RECENT_MENTIONS,
|
||||
value: JSON.stringify(results.order),
|
||||
};
|
||||
|
||||
promises.push(operator.handleSystem({
|
||||
await operator.handleSystem({
|
||||
systems: [mentions],
|
||||
prepareRecordsOnly: true,
|
||||
}));
|
||||
prepareRecordsOnly: false,
|
||||
});
|
||||
|
||||
return results;
|
||||
} catch (error) {
|
||||
|
|
|
|||
|
|
@ -11,23 +11,26 @@ export const getNeededAtMentionedUsernames = (usernames: Set<string>, posts: Pos
|
|||
posts.forEach((p) => {
|
||||
let match;
|
||||
while ((match = pattern.exec(p.message)) !== null) {
|
||||
const lowercaseMatch1 = match[1].toLowerCase();
|
||||
const lowercaseMatch2 = match[2].toLowerCase();
|
||||
|
||||
// match[1] is the matched mention including trailing punctuation
|
||||
// match[2] is the matched mention without trailing punctuation
|
||||
if (General.SPECIAL_MENTIONS.has(match[2])) {
|
||||
if (General.SPECIAL_MENTIONS.has(lowercaseMatch2)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (match[1] === excludeUsername || match[2] === excludeUsername) {
|
||||
if (lowercaseMatch1 === excludeUsername || lowercaseMatch2 === excludeUsername) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (usernames.has(match[1]) || usernames.has(match[2])) {
|
||||
if (usernames.has(lowercaseMatch1) || usernames.has(lowercaseMatch2)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// If there's no trailing punctuation, this will only add 1 item to the set
|
||||
usernamesToLoad.add(match[1]);
|
||||
usernamesToLoad.add(match[2]);
|
||||
usernamesToLoad.add(lowercaseMatch1);
|
||||
usernamesToLoad.add(lowercaseMatch2);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue