Skip to content

Commit

Permalink
if (notes.length === 0) return;
Browse files Browse the repository at this point in the history
  • Loading branch information
tamaina committed Feb 21, 2024
1 parent 6be1d98 commit 22e2324
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 2 additions & 0 deletions packages/backend/src/core/NoteReadService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ export class NoteReadService implements OnApplicationShutdown {
userId: MiUser['id'],
notes: (MiNote | Packed<'Note'>)[],
): Promise<void> {
if (notes.length === 0) return;

const readMentions: (MiNote | Packed<'Note'>)[] = [];
const readSpecifiedNotes: (MiNote | Packed<'Note'>)[] = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,7 @@ export class NotificationEntityService implements OnModuleInit {
}
return acc;
}, 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) {
// console.error('error thrown by NoteReadService.read', e);
}
Expand Down
4 changes: 1 addition & 3 deletions packages/backend/src/server/api/endpoints/antennas/notes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // 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);
});
Expand Down

0 comments on commit 22e2324

Please sign in to comment.