Skip to content

Commit

Permalink
ドキュメントコメントの追加と型定義の調整
Browse files Browse the repository at this point in the history
  • Loading branch information
okayurisotto committed Feb 18, 2024
1 parent 0bd2465 commit eda8c82
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/backend/src/core/ReactionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,12 @@ export class ReactionService {
//#endregion
}

/**
* 文字列タイプのレガシーな形式のリアクションを現在の形式に変換しつつ、
* データベース上には存在する「0個のリアクションがついている」という情報を削除する。
*/
@bindThis
public convertLegacyReactions(reactions: Record<string, number>) {
public convertLegacyReactions(reactions: MiNote['reactions']): MiNote['reactions'] {
return Object.entries(reactions)
.filter(([, count]) => {
// `ReactionService.prototype.delete`ではリアクション削除時に、
Expand All @@ -340,7 +344,7 @@ export class ReactionService {

return [key, count] as const;
})
.reduce<Record<string, number>>((acc, [key, count]) => {
.reduce<MiNote['reactions']>((acc, [key, count]) => {
// unchecked indexed access
const prevCount = acc[key] as number | undefined;

Expand Down

0 comments on commit eda8c82

Please sign in to comment.