Fix filtering, allow filtering by mentioned usernames

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2022-03-26 10:55:53 +01:00
parent 4782afed18
commit ea57d1c4a7
2 changed files with 8 additions and 1 deletions

View file

@ -27,6 +27,7 @@ export const StatusRecord = ImmutableRecord({
emojis: ImmutableList(), emojis: ImmutableList(),
favourited: false, favourited: false,
favourites_count: 0, favourites_count: 0,
filtered: false,
in_reply_to_account_id: null, in_reply_to_account_id: null,
in_reply_to_id: null, in_reply_to_id: null,
id: '', id: '',

View file

@ -54,14 +54,20 @@ const getPollOptionTitles = (status: StatusRecord): Array<string> => {
return status.poll?.options.map(({ title }: { title: string }) => title); return status.poll?.options.map(({ title }: { title: string }) => title);
}; };
// Gets usernames of mentioned users from status
const getMentionedUsernames = (status: StatusRecord): Array<string> => {
return (status as any).mentions?.map(({ username }: { username: string }) => username);
};
// Creates search text from the status // Creates search text from the status
const buildSearchContent = (status: StatusRecord): string => { const buildSearchContent = (status: StatusRecord): string => {
const pollOptionTitles = getPollOptionTitles(status); const pollOptionTitles = getPollOptionTitles(status);
const mentionedUsernames = getMentionedUsernames(status);
const fields = ImmutableList([ const fields = ImmutableList([
status.spoiler_text, status.spoiler_text,
status.content, status.content,
]).concat(pollOptionTitles); ]).concat(pollOptionTitles).concat(mentionedUsernames);
return unescapeHTML(fields.join('\n\n')); return unescapeHTML(fields.join('\n\n'));
}; };