diff options
| author | Aya Morisawa <AyaMorisawa4869@gmail.com> | 2018-09-07 00:10:03 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2018-09-07 00:10:03 +0900 |
| commit | ff0a05a2d67f45ec9ff06d50c5be821d559c2528 (patch) | |
| tree | 1f9017e908a4852d7a4c51a85f2c8cbaca2be79b /src/services/note/create.ts | |
| parent | Fix bug (#2643) (diff) | |
| download | sharkey-ff0a05a2d67f45ec9ff06d50c5be821d559c2528.tar.gz sharkey-ff0a05a2d67f45ec9ff06d50c5be821d559c2528.tar.bz2 sharkey-ff0a05a2d67f45ec9ff06d50c5be821d559c2528.zip | |
Add unique function (#2644)
Diffstat (limited to 'src/services/note/create.ts')
| -rw-r--r-- | src/services/note/create.ts | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/services/note/create.ts b/src/services/note/create.ts index 4759497c63..c08836c94b 100644 --- a/src/services/note/create.ts +++ b/src/services/note/create.ts @@ -24,7 +24,7 @@ import isQuote from '../../misc/is-quote'; import { TextElementMention } from '../../mfm/parse/elements/mention'; import { TextElementHashtag } from '../../mfm/parse/elements/hashtag'; import { updateNoteStats } from '../update-chart'; -import { erase } from '../../prelude/array'; +import { erase, unique } from '../../prelude/array'; type NotificationType = 'reply' | 'renote' | 'quote' | 'mention'; @@ -385,7 +385,7 @@ function extractHashtags(tokens: ReturnType<typeof parse>): string[] { .map(t => (t as TextElementHashtag).hashtag) .filter(tag => tag.length <= 100); - return [...new Set(hashtags)]; + return unique(hashtags); } function index(note: INote) { @@ -542,12 +542,12 @@ function incNotesCount(user: IUser) { async function extractMentionedUsers(tokens: ReturnType<typeof parse>): Promise<IUser[]> { if (tokens == null) return []; - const mentionTokens = [...new Set( + const mentionTokens = unique( tokens .filter(t => t.type == 'mention') as TextElementMention[] - )]; + ); - const mentionedUsers = [...new Set( + const mentionedUsers = unique( erase(null, await Promise.all(mentionTokens.map(async m => { try { return await resolveUser(m.username, m.host); @@ -555,7 +555,7 @@ async function extractMentionedUsers(tokens: ReturnType<typeof parse>): Promise< return null; } }))) - )]; + ); return mentionedUsers; } |