pl-fe: Types improvements
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
8bc30f18f8
commit
c8b68625e1
3 changed files with 5 additions and 3 deletions
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
}, {});
|
||||
|
|
Loading…
Reference in a new issue