if (notes.length === 0) return;

This commit is contained in:
tamaina 2024-02-21 18:46:52 +00:00
parent 6be1d986cd
commit 22e2324f96
3 changed files with 4 additions and 6 deletions

View File

@ -88,6 +88,8 @@ export class NoteReadService implements OnApplicationShutdown {
userId: MiUser['id'], userId: MiUser['id'],
notes: (MiNote | Packed<'Note'>)[], notes: (MiNote | Packed<'Note'>)[],
): Promise<void> { ): Promise<void> {
if (notes.length === 0) return;
const readMentions: (MiNote | Packed<'Note'>)[] = []; const readMentions: (MiNote | Packed<'Note'>)[] = [];
const readSpecifiedNotes: (MiNote | Packed<'Note'>)[] = []; const readSpecifiedNotes: (MiNote | Packed<'Note'>)[] = [];

View File

@ -237,9 +237,7 @@ export class NotificationEntityService implements OnModuleInit {
} }
return acc; return acc;
}, new Set<Packed<'Note'>>()); }, new Set<Packed<'Note'>>());
if (notesToRead.size > 0) {
trackPromise(this.noteReadService.read(meId, Array.from(notesToRead))); trackPromise(this.noteReadService.read(meId, Array.from(notesToRead)));
}
} catch (e) { } catch (e) {
// console.error('error thrown by NoteReadService.read', e); // console.error('error thrown by NoteReadService.read', e);
} }

View File

@ -124,9 +124,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
notes.sort((a, b) => a.id > b.id ? -1 : 1); 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); return await this.noteEntityService.packMany(notes, me);
}); });