Merge remote-tracking branch 'parent/main' into upstream-20241216
This commit is contained in:
commit
3784ad273c
555 changed files with 7564 additions and 3363 deletions
|
@ -1,12 +1,12 @@
|
|||
import type { RecordOf } from 'immutable';
|
||||
import { Record } from 'immutable';
|
||||
import type { RecordOf, List as ImmutableList } from 'immutable';
|
||||
import { Record as ImmutableRecord, isList } from 'immutable';
|
||||
|
||||
import type { ApiCustomEmojiJSON } from 'mastodon/api_types/custom_emoji';
|
||||
|
||||
type CustomEmojiShape = Required<ApiCustomEmojiJSON>; // no changes from server shape
|
||||
export type CustomEmoji = RecordOf<CustomEmojiShape>;
|
||||
|
||||
export const CustomEmojiFactory = Record<CustomEmojiShape>({
|
||||
export const CustomEmojiFactory = ImmutableRecord<CustomEmojiShape>({
|
||||
shortcode: '',
|
||||
static_url: '',
|
||||
url: '',
|
||||
|
@ -18,3 +18,20 @@ export const CustomEmojiFactory = Record<CustomEmojiShape>({
|
|||
aliases: [],
|
||||
license: '',
|
||||
});
|
||||
|
||||
export type EmojiMap = Record<string, ApiCustomEmojiJSON>;
|
||||
|
||||
export function makeEmojiMap(
|
||||
emojis: ApiCustomEmojiJSON[] | ImmutableList<CustomEmoji>,
|
||||
) {
|
||||
if (isList(emojis)) {
|
||||
return emojis.reduce<EmojiMap>((obj, emoji) => {
|
||||
obj[`:${emoji.shortcode}:`] = emoji.toJS() as ApiCustomEmojiJSON;
|
||||
return obj;
|
||||
}, {});
|
||||
} else
|
||||
return emojis.reduce<EmojiMap>((obj, emoji) => {
|
||||
obj[`:${emoji.shortcode}:`] = emoji;
|
||||
return obj;
|
||||
}, {});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue