mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-14 20:25:39 +02:00
Merge branch 'develop' into room
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