pl-fe: Types improvements

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2024-10-06 00:09:12 +02:00
parent 8bc30f18f8
commit c8b68625e1
3 changed files with 5 additions and 3 deletions

View file

@ -21,7 +21,7 @@ const normalizePoll = (poll: Exclude<BaseStatus['poll'], null>) => {
};
};
const normalizePollEdit = (poll: Exclude<BaseStatusEdit['poll'], null>, emojis?: Array<CustomEmoji>) => {
const normalizePollEdit = (poll: Exclude<BaseStatusEdit['poll'], null>, emojis: Array<CustomEmoji>) => {
const emojiMap = makeEmojiMap(emojis);
return {
...poll,

View file

@ -13,7 +13,7 @@ import type { StatusEdit as BaseStatusEdit } from 'pl-api';
const normalizeStatusEdit = (statusEdit: BaseStatusEdit) => {
const emojiMap = makeEmojiMap(statusEdit.emojis);
const poll = statusEdit.poll ? normalizePollEdit(statusEdit.poll) : null;
const poll = statusEdit.poll ? normalizePollEdit(statusEdit.poll, statusEdit.emojis) : null;
return {
...statusEdit,

View file

@ -1,4 +1,6 @@
const makeEmojiMap = (emojis: any) => emojis.reduce((obj: any, emoji: any) => {
import type { CustomEmoji } from 'pl-api';
const makeEmojiMap = (emojis: Array<CustomEmoji>) => emojis.reduce((obj: Record<string, CustomEmoji>, emoji: CustomEmoji) => {
obj[`:${emoji.shortcode}:`] = emoji;
return obj;
}, {});