mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-14 16:56:00 +02:00
enhance: アバターデコレーションへのカテゴリの導入 (#17034)
* feat(backend): AvatarDecorationにcategoryを追加し、関連APIのプロパティ・戻り値にも反映 * feat(frontend): アバターデコレーションのカテゴリ設定機能 * chore(frontend): 管理画面とユーザー側の画面で、アバターデコレーションのグループ化のコードをある程度統一 * CHANGELOGを更新 * fix: group-avatar-decorations.tsを使用するよう修正 * chore: コーディング規約への準拠 * 型エラーを解消
This commit is contained in:
25
packages/frontend/src/utility/group-avatar-decorations.ts
Normal file
25
packages/frontend/src/utility/group-avatar-decorations.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
type AvatarDecorationBase = { category?: string | null | undefined };
|
||||
|
||||
/**
|
||||
* アバターデコレーションをカテゴリごとにグループ化します。
|
||||
* @param decorations アバターデコレーションの配列
|
||||
* @returns カテゴリごとにグループ化されたアバターデコレーションオブジェクト
|
||||
*/
|
||||
export function groupAvatarDecorations<T extends AvatarDecorationBase>(decorations: T[]) {
|
||||
const grouped: Record<string, T[]> = {};
|
||||
|
||||
for (const decoration of decorations) {
|
||||
const category = decoration.category ?? '';
|
||||
if (!(category in grouped)) {
|
||||
grouped[category] = [];
|
||||
}
|
||||
grouped[category].push(decoration);
|
||||
}
|
||||
|
||||
return grouped;
|
||||
}
|
||||
Reference in New Issue
Block a user