mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-21 18:05:29 +02:00
* feat(backend): AvatarDecorationにcategoryを追加し、関連APIのプロパティ・戻り値にも反映 * feat(frontend): アバターデコレーションのカテゴリ設定機能 * chore(frontend): 管理画面とユーザー側の画面で、アバターデコレーションのグループ化のコードをある程度統一 * CHANGELOGを更新 * fix: group-avatar-decorations.tsを使用するよう修正 * chore: コーディング規約への準拠 * 型エラーを解消
26 lines
790 B
TypeScript
26 lines
790 B
TypeScript
/*
|
|
* 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;
|
|
}
|