Skip to content
This repository has been archived by the owner on Jun 29, 2024. It is now read-only.

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
syuilo committed Feb 24, 2024
1 parent e3dd3f6 commit 41747b6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions packages/backend/src/core/entities/NoteReactionEntityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,19 @@ export class NoteReactionEntityService implements OnModuleInit {
} : {}),
};
}

@bindThis
public async packMany(
reactions: MiNoteReaction[],
me?: { id: MiUser['id'] } | null | undefined,
options?: {
withNote: boolean;
},
): Promise<Packed<'NoteReaction'>[]> {
const opts = Object.assign({
withNote: false,
}, options);

return Promise.all(reactions.map(reaction => this.pack(reaction, me, opts)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
.limit(ps.limit)
.getMany();

return await Promise.all(reactions.map(reaction => this.noteReactionEntityService.pack(reaction, me, { withNote: true })));
return await this.noteReactionEntityService.packMany(reactions, me, { withNote: true });
});
}
}

0 comments on commit 41747b6

Please sign in to comment.