pl-fe: Remove some any
s
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
c8b68625e1
commit
26b922d4f6
10 changed files with 35 additions and 27 deletions
|
@ -428,7 +428,7 @@ const submitCompose = (composeId: string, opts: SubmitComposeOpts = {}) =>
|
||||||
|
|
||||||
const poll = params.poll;
|
const poll = params.poll;
|
||||||
if (poll?.options_map) {
|
if (poll?.options_map) {
|
||||||
poll.options.forEach((option: any, index: number) => poll.options_map![index][compose.language!] = option);
|
poll.options.forEach((option, index: number) => poll.options_map![index][compose.language!] = option);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -491,7 +491,7 @@ const uploadCompose = (composeId: string, files: FileList, intl: IntlShape) =>
|
||||||
intl,
|
intl,
|
||||||
(data) => dispatch(uploadComposeSuccess(composeId, data, f)),
|
(data) => dispatch(uploadComposeSuccess(composeId, data, f)),
|
||||||
(error) => dispatch(uploadComposeFail(composeId, error)),
|
(error) => dispatch(uploadComposeFail(composeId, error)),
|
||||||
({ loaded }: any) => {
|
({ loaded }) => {
|
||||||
progress[i] = loaded;
|
progress[i] = loaded;
|
||||||
dispatch(uploadComposeProgress(composeId, progress.reduce((a, v) => a + v, 0), total));
|
dispatch(uploadComposeProgress(composeId, progress.reduce((a, v) => a + v, 0), total));
|
||||||
},
|
},
|
||||||
|
|
|
@ -57,7 +57,7 @@ const listAccounts = async (response: PaginatedResponse<Account>) => {
|
||||||
Array.prototype.push.apply(followings, response.items);
|
Array.prototype.push.apply(followings, response.items);
|
||||||
}
|
}
|
||||||
|
|
||||||
accounts = followings.map((account: any) => normalizeAccount(account).fqn);
|
accounts = followings.map((account) => normalizeAccount(account).fqn);
|
||||||
return Array.from(new Set(accounts));
|
return Array.from(new Set(accounts));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ interface IAccount {
|
||||||
hidden?: boolean;
|
hidden?: boolean;
|
||||||
hideActions?: boolean;
|
hideActions?: boolean;
|
||||||
id?: string;
|
id?: string;
|
||||||
onActionClick?: (account: any) => void;
|
onActionClick?: (account: AccountSchema) => void;
|
||||||
showAccountHoverCard?: boolean;
|
showAccountHoverCard?: boolean;
|
||||||
timestamp?: string;
|
timestamp?: string;
|
||||||
timestampUrl?: string;
|
timestampUrl?: string;
|
||||||
|
|
|
@ -31,7 +31,7 @@ const Emoji: React.FC<IEmoji> = ({ emoji, emojiMap, hovered }) => {
|
||||||
src={joinPublicPath(`packs/emoji/${filename}.svg`)}
|
src={joinPublicPath(`packs/emoji/${filename}.svg`)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
} else if (emojiMap.get(emoji as any)) {
|
} else if (emojiMap.get(emoji)) {
|
||||||
const filename = (autoPlayGif || hovered) ? emojiMap.getIn([emoji, 'url']) : emojiMap.getIn([emoji, 'static_url']);
|
const filename = (autoPlayGif || hovered) ? emojiMap.getIn([emoji, 'url']) : emojiMap.getIn([emoji, 'static_url']);
|
||||||
const shortCode = `:${emoji}:`;
|
const shortCode = `:${emoji}:`;
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ const showStatusHoverCard = debounce((openStatusHoverCard, ref, statusId) => {
|
||||||
}, 300);
|
}, 300);
|
||||||
|
|
||||||
interface IHoverStatusWrapper {
|
interface IHoverStatusWrapper {
|
||||||
statusId: any;
|
statusId: string;
|
||||||
inline: boolean;
|
inline: boolean;
|
||||||
className?: string;
|
className?: string;
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
|
|
|
@ -664,6 +664,18 @@ const StatusActionBar: React.FC<IStatusActionBar> = ({
|
||||||
replyTitle = intl.formatMessage(messages.replies_disabled_group);
|
replyTitle = intl.formatMessage(messages.replies_disabled_group);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const replyButton = (
|
||||||
|
<StatusActionButton
|
||||||
|
title={replyTitle}
|
||||||
|
icon={require('@tabler/icons/outline/message-circle.svg')}
|
||||||
|
onClick={handleReplyClick}
|
||||||
|
count={replyCount}
|
||||||
|
text={withLabels ? intl.formatMessage(messages.reply) : undefined}
|
||||||
|
disabled={replyDisabled}
|
||||||
|
theme={statusActionButtonTheme}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
const reblogMenu = [{
|
const reblogMenu = [{
|
||||||
text: intl.formatMessage(status.reblogged ? messages.cancel_reblog_private : messages.reblog),
|
text: intl.formatMessage(status.reblogged ? messages.cancel_reblog_private : messages.reblog),
|
||||||
action: handleReblogClick,
|
action: handleReblogClick,
|
||||||
|
@ -714,20 +726,14 @@ const StatusActionBar: React.FC<IStatusActionBar> = ({
|
||||||
onClick={e => e.stopPropagation()}
|
onClick={e => e.stopPropagation()}
|
||||||
alignItems='center'
|
alignItems='center'
|
||||||
>
|
>
|
||||||
|
{status.group ? (
|
||||||
<GroupPopover
|
<GroupPopover
|
||||||
group={status.group as any}
|
group={status.group}
|
||||||
isEnabled={replyDisabled}
|
isEnabled={replyDisabled}
|
||||||
>
|
>
|
||||||
<StatusActionButton
|
{replyButton}
|
||||||
title={replyTitle}
|
|
||||||
icon={require('@tabler/icons/outline/message-circle.svg')}
|
|
||||||
onClick={handleReplyClick}
|
|
||||||
count={replyCount}
|
|
||||||
text={withLabels ? intl.formatMessage(messages.reply) : undefined}
|
|
||||||
disabled={replyDisabled}
|
|
||||||
theme={statusActionButtonTheme}
|
|
||||||
/>
|
|
||||||
</GroupPopover>
|
</GroupPopover>
|
||||||
|
) : replyButton}
|
||||||
|
|
||||||
{(features.quotePosts && me) ? (
|
{(features.quotePosts && me) ? (
|
||||||
<DropdownMenu
|
<DropdownMenu
|
||||||
|
|
|
@ -82,7 +82,7 @@ const StatusReplyMentions: React.FC<IStatusReplyMentions> = ({ status, hoverable
|
||||||
accounts: <FormattedList type='conjunction' value={accounts} />,
|
accounts: <FormattedList type='conjunction' value={accounts} />,
|
||||||
// @ts-ignore wtf?
|
// @ts-ignore wtf?
|
||||||
hover: (children: React.ReactNode) => {
|
hover: (children: React.ReactNode) => {
|
||||||
if (hoverable) {
|
if (hoverable && status.in_reply_to_id) {
|
||||||
return (
|
return (
|
||||||
<HoverStatusWrapper statusId={status.in_reply_to_id} inline>
|
<HoverStatusWrapper statusId={status.in_reply_to_id} inline>
|
||||||
<span
|
<span
|
||||||
|
|
|
@ -189,7 +189,7 @@ const parseHTML = (str: string): { text: boolean; data: string }[] => {
|
||||||
return tokens;
|
return tokens;
|
||||||
};
|
};
|
||||||
|
|
||||||
const emojify = (str: string, customEmojis = {}) =>
|
const emojify = (str: string, customEmojis: Record<string, BaseCustomEmoji> = {}) =>
|
||||||
parseHTML(str)
|
parseHTML(str)
|
||||||
.map(({ text, data }) => {
|
.map(({ text, data }) => {
|
||||||
if (!text) return data;
|
if (!text) return data;
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
import escapeTextContentForBrowser from 'escape-html';
|
import escapeTextContentForBrowser from 'escape-html';
|
||||||
import DOMPurify from 'isomorphic-dompurify';
|
import DOMPurify from 'isomorphic-dompurify';
|
||||||
import { Status as BaseStatus, StatusEdit as BaseStatusEdit, CustomEmoji } from 'pl-api';
|
|
||||||
|
|
||||||
import emojify from 'pl-fe/features/emoji';
|
import emojify from 'pl-fe/features/emoji';
|
||||||
import { makeEmojiMap } from 'pl-fe/utils/normalizers';
|
import { makeEmojiMap } from 'pl-fe/utils/normalizers';
|
||||||
|
|
||||||
const sanitizeTitle = (text: string, emojiMap: any) => DOMPurify.sanitize(emojify(escapeTextContentForBrowser(text), emojiMap), { ALLOWED_TAGS: ['img'] });
|
import type { Status as BaseStatus, StatusEdit as BaseStatusEdit, CustomEmoji } from 'pl-api';
|
||||||
|
|
||||||
|
const sanitizeTitle = (text: string, emojiMap: Record<string, CustomEmoji>) => DOMPurify.sanitize(emojify(escapeTextContentForBrowser(text), emojiMap), { ALLOWED_TAGS: ['img'] });
|
||||||
|
|
||||||
const normalizePoll = (poll: Exclude<BaseStatus['poll'], null>) => {
|
const normalizePoll = (poll: Exclude<BaseStatus['poll'], null>) => {
|
||||||
const emojiMap = makeEmojiMap(poll.emojis);
|
const emojiMap = makeEmojiMap(poll.emojis);
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
import escapeTextContentForBrowser from 'escape-html';
|
import escapeTextContentForBrowser from 'escape-html';
|
||||||
import DOMPurify from 'isomorphic-dompurify';
|
import DOMPurify from 'isomorphic-dompurify';
|
||||||
import { type Account as BaseAccount, type Status as BaseStatus, type MediaAttachment, mentionSchema, type Translation } from 'pl-api';
|
import { type Account as BaseAccount, type Status as BaseStatus, type CustomEmoji, type MediaAttachment, mentionSchema, type Translation } from 'pl-api';
|
||||||
|
|
||||||
import emojify from 'pl-fe/features/emoji';
|
import emojify from 'pl-fe/features/emoji';
|
||||||
import { unescapeHTML } from 'pl-fe/utils/html';
|
import { unescapeHTML } from 'pl-fe/utils/html';
|
||||||
|
@ -62,8 +62,8 @@ const buildSearchContent = (status: Pick<BaseStatus, 'poll' | 'mentions' | 'spoi
|
||||||
return unescapeHTML(fields.join('\n\n')) || '';
|
return unescapeHTML(fields.join('\n\n')) || '';
|
||||||
};
|
};
|
||||||
|
|
||||||
const calculateContent = (text: string, emojiMap: any) => emojify(text, emojiMap);
|
const calculateContent = (text: string, emojiMap: Record<string, CustomEmoji>) => emojify(text, emojiMap);
|
||||||
const calculateSpoiler = (text: string, emojiMap: any) => DOMPurify.sanitize(emojify(escapeTextContentForBrowser(text), emojiMap), { USE_PROFILES: { html: true } });
|
const calculateSpoiler = (text: string, emojiMap: Record<string, CustomEmoji>) => DOMPurify.sanitize(emojify(escapeTextContentForBrowser(text), emojiMap), { USE_PROFILES: { html: true } });
|
||||||
|
|
||||||
const calculateStatus = (status: BaseStatus, oldStatus?: OldStatus): CalculatedValues => {
|
const calculateStatus = (status: BaseStatus, oldStatus?: OldStatus): CalculatedValues => {
|
||||||
if (oldStatus && oldStatus.content === status.content && oldStatus.spoiler_text === status.spoiler_text) {
|
if (oldStatus && oldStatus.content === status.content && oldStatus.spoiler_text === status.spoiler_text) {
|
||||||
|
|
Loading…
Reference in a new issue