From 22e2324f9633bddba50769ef838bc5ddb4564c88 Mon Sep 17 00:00:00 2001 From: tamaina Date: Wed, 21 Feb 2024 18:46:52 +0000 Subject: [PATCH] if (notes.length === 0) return; --- packages/backend/src/core/NoteReadService.ts | 2 ++ .../backend/src/core/entities/NotificationEntityService.ts | 4 +--- packages/backend/src/server/api/endpoints/antennas/notes.ts | 4 +--- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/backend/src/core/NoteReadService.ts b/packages/backend/src/core/NoteReadService.ts index feef024602ff..b3746b62ea0e 100644 --- a/packages/backend/src/core/NoteReadService.ts +++ b/packages/backend/src/core/NoteReadService.ts @@ -88,6 +88,8 @@ export class NoteReadService implements OnApplicationShutdown { userId: MiUser['id'], notes: (MiNote | Packed<'Note'>)[], ): Promise { + if (notes.length === 0) return; + const readMentions: (MiNote | Packed<'Note'>)[] = []; const readSpecifiedNotes: (MiNote | Packed<'Note'>)[] = []; diff --git a/packages/backend/src/core/entities/NotificationEntityService.ts b/packages/backend/src/core/entities/NotificationEntityService.ts index cc40a3f754a9..e10b68df02a7 100644 --- a/packages/backend/src/core/entities/NotificationEntityService.ts +++ b/packages/backend/src/core/entities/NotificationEntityService.ts @@ -237,9 +237,7 @@ export class NotificationEntityService implements OnModuleInit { } return acc; }, new Set>()); - if (notesToRead.size > 0) { - trackPromise(this.noteReadService.read(meId, Array.from(notesToRead))); - } + trackPromise(this.noteReadService.read(meId, Array.from(notesToRead))); } catch (e) { // console.error('error thrown by NoteReadService.read', e); } diff --git a/packages/backend/src/server/api/endpoints/antennas/notes.ts b/packages/backend/src/server/api/endpoints/antennas/notes.ts index 39f3fab21ee0..f4dfe1ecc4d7 100644 --- a/packages/backend/src/server/api/endpoints/antennas/notes.ts +++ b/packages/backend/src/server/api/endpoints/antennas/notes.ts @@ -124,9 +124,7 @@ export default class extends Endpoint { // eslint- notes.sort((a, b) => a.id > b.id ? -1 : 1); } - if (notes.length > 0) { - this.noteReadService.read(me.id, notes); - } + this.noteReadService.read(me.id, notes); return await this.noteEntityService.packMany(notes, me); });