From f5091d524b1f6faef1ecdd774882c0df05753ae8 Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 25 Apr 2019 04:17:03 +0900 Subject: [PATCH] Refactorgin --- src/services/note/create.ts | 139 ++++++++++++++++++------------------ 1 file changed, 68 insertions(+), 71 deletions(-) diff --git a/src/services/note/create.ts b/src/services/note/create.ts index 2195ecc55f..53e77b4ef2 100644 --- a/src/services/note/create.ts +++ b/src/services/note/create.ts @@ -106,8 +106,6 @@ type Option = { }; export default async (user: User, data: Option, silent = false) => new Promise(async (res, rej) => { - const isFirstNote = user.notesCount === 0; - if (data.createdAt == null) data.createdAt = new Date(); if (data.visibility == null) data.visibility = 'public'; if (data.viaMobile == null) data.viaMobile = false; @@ -195,8 +193,6 @@ export default async (user: User, data: Option, silent = false) => new Promise new Promise new Promise { - nm.deliver(); - }); + Promise.all(nmRelatedPromises).then(() => { + nm.deliver(); + }); + } // Register to search database index(note);