From d53b837994b8256b2bcf1cb7dcabb07a7d6af837 Mon Sep 17 00:00:00 2001 From: taichan Date: Tue, 20 Feb 2024 15:03:10 +0900 Subject: [PATCH] add filter notification is not null --- .../src/core/entities/NotificationEntityService.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/backend/src/core/entities/NotificationEntityService.ts b/packages/backend/src/core/entities/NotificationEntityService.ts index cbe93fc0c0..ebfb9d9388 100644 --- a/packages/backend/src/core/entities/NotificationEntityService.ts +++ b/packages/backend/src/core/entities/NotificationEntityService.ts @@ -114,7 +114,7 @@ export class NotificationEntityService implements OnModuleInit { public async packMany( notifications: MiNotification[], meId: MiUser['id'], - ) { + ): Promise { if (notifications.length === 0) return []; let validNotifications = notifications; @@ -147,10 +147,10 @@ export class NotificationEntityService implements OnModuleInit { validNotifications = validNotifications.filter(x => (x.type !== 'receiveFollowRequest') || reqs.some(r => r.followerId === x.notifierId)); } - return await Promise.all(validNotifications.map(x => this.pack(x, meId, {}, { + return (await Promise.all(validNotifications.map(x => this.pack(x, meId, {}, { packedNotes, packedUsers, - }))); + })))).filter(isNotNull); } @bindThis @@ -248,7 +248,7 @@ export class NotificationEntityService implements OnModuleInit { public async packGroupedMany( notifications: MiGroupedNotification[], meId: MiUser['id'], - ) { + ) : Promise { if (notifications.length === 0) return []; let validNotifications = notifications; @@ -286,10 +286,10 @@ export class NotificationEntityService implements OnModuleInit { validNotifications = validNotifications.filter(x => (x.type !== 'receiveFollowRequest') || reqs.some(r => r.followerId === x.notifierId)); } - return await Promise.all(validNotifications.map(x => this.packGrouped(x, meId, {}, { + return (await Promise.all(validNotifications.map(x => this.packGrouped(x, meId, {}, { packedNotes, packedUsers, - }))); + })))).filter(isNotNull); } /**