diff options
| author | Aya Morisawa <AyaMorisawa4869@gmail.com> | 2018-09-07 00:02:55 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2018-09-07 00:02:55 +0900 |
| commit | 00d79487cd89f3cae675ecc0392c47ba547b69a5 (patch) | |
| tree | a55b9cf9240fce4ca853d78e004dac75f8c06002 /src/services/note | |
| parent | Add concat function (#2640) (diff) | |
| download | sharkey-00d79487cd89f3cae675ecc0392c47ba547b69a5.tar.gz sharkey-00d79487cd89f3cae675ecc0392c47ba547b69a5.tar.bz2 sharkey-00d79487cd89f3cae675ecc0392c47ba547b69a5.zip | |
Add erase function (#2641)
Diffstat (limited to 'src/services/note')
| -rw-r--r-- | src/services/note/create.ts | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/services/note/create.ts b/src/services/note/create.ts index 11e3755863..4759497c63 100644 --- a/src/services/note/create.ts +++ b/src/services/note/create.ts @@ -24,6 +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'; type NotificationType = 'reply' | 'renote' | 'quote' | 'mention'; @@ -103,7 +104,7 @@ export default async (user: IUser, data: Option, silent = false) => new Promise< if (data.viaMobile == null) data.viaMobile = false; if (data.visibleUsers) { - data.visibleUsers = data.visibleUsers.filter(x => x != null); + data.visibleUsers = erase(null, data.visibleUsers); } if (data.reply && data.reply.deletedAt != null) { @@ -547,13 +548,13 @@ async function extractMentionedUsers(tokens: ReturnType<typeof parse>): Promise< )]; const mentionedUsers = [...new Set( - (await Promise.all(mentionTokens.map(async m => { + erase(null, await Promise.all(mentionTokens.map(async m => { try { return await resolveUser(m.username, m.host); } catch (e) { return null; } - }))).filter(x => x != null) + }))) )]; return mentionedUsers; |