pl-fe: Remove some anys

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2024-10-06 00:17:19 +02:00
parent c8b68625e1
commit 26b922d4f6
10 changed files with 35 additions and 27 deletions

View file

@ -428,7 +428,7 @@ const submitCompose = (composeId: string, opts: SubmitComposeOpts = {}) =>
const poll = params.poll;
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,
(data) => dispatch(uploadComposeSuccess(composeId, data, f)),
(error) => dispatch(uploadComposeFail(composeId, error)),
({ loaded }: any) => {
({ loaded }) => {
progress[i] = loaded;
dispatch(uploadComposeProgress(composeId, progress.reduce((a, v) => a + v, 0), total));
},

View file

@ -57,7 +57,7 @@ const listAccounts = async (response: PaginatedResponse<Account>) => {
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));
};

View file

@ -81,7 +81,7 @@ interface IAccount {
hidden?: boolean;
hideActions?: boolean;
id?: string;
onActionClick?: (account: any) => void;
onActionClick?: (account: AccountSchema) => void;
showAccountHoverCard?: boolean;
timestamp?: string;
timestampUrl?: string;

View file

@ -31,7 +31,7 @@ const Emoji: React.FC<IEmoji> = ({ emoji, emojiMap, hovered }) => {
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 shortCode = `:${emoji}:`;

View file

@ -10,7 +10,7 @@ const showStatusHoverCard = debounce((openStatusHoverCard, ref, statusId) => {
}, 300);
interface IHoverStatusWrapper {
statusId: any;
statusId: string;
inline: boolean;
className?: string;
children: React.ReactNode;

View file

@ -664,6 +664,18 @@ const StatusActionBar: React.FC<IStatusActionBar> = ({
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 = [{
text: intl.formatMessage(status.reblogged ? messages.cancel_reblog_private : messages.reblog),
action: handleReblogClick,
@ -714,20 +726,14 @@ const StatusActionBar: React.FC<IStatusActionBar> = ({
onClick={e => e.stopPropagation()}
alignItems='center'
>
{status.group ? (
<GroupPopover
group={status.group as any}
group={status.group}
isEnabled={replyDisabled}
>
<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}
/>
{replyButton}
</GroupPopover>
) : replyButton}
{(features.quotePosts && me) ? (
<DropdownMenu

View file

@ -82,7 +82,7 @@ const StatusReplyMentions: React.FC<IStatusReplyMentions> = ({ status, hoverable
accounts: <FormattedList type='conjunction' value={accounts} />,
// @ts-ignore wtf?
hover: (children: React.ReactNode) => {
if (hoverable) {
if (hoverable && status.in_reply_to_id) {
return (
<HoverStatusWrapper statusId={status.in_reply_to_id} inline>
<span

View file

@ -189,7 +189,7 @@ const parseHTML = (str: string): { text: boolean; data: string }[] => {
return tokens;
};
const emojify = (str: string, customEmojis = {}) =>
const emojify = (str: string, customEmojis: Record<string, BaseCustomEmoji> = {}) =>
parseHTML(str)
.map(({ text, data }) => {
if (!text) return data;

View file

@ -1,11 +1,13 @@
import escapeTextContentForBrowser from 'escape-html';
import DOMPurify from 'isomorphic-dompurify';
import { Status as BaseStatus, StatusEdit as BaseStatusEdit, CustomEmoji } from 'pl-api';
import emojify from 'pl-fe/features/emoji';
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 emojiMap = makeEmojiMap(poll.emojis);

View file

@ -5,7 +5,7 @@
*/
import escapeTextContentForBrowser from 'escape-html';
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 { unescapeHTML } from 'pl-fe/utils/html';
@ -62,8 +62,8 @@ const buildSearchContent = (status: Pick<BaseStatus, 'poll' | 'mentions' | 'spoi
return unescapeHTML(fields.join('\n\n')) || '';
};
const calculateContent = (text: string, emojiMap: any) => emojify(text, emojiMap);
const calculateSpoiler = (text: string, emojiMap: any) => DOMPurify.sanitize(emojify(escapeTextContentForBrowser(text), emojiMap), { USE_PROFILES: { html: true } });
const calculateContent = (text: string, emojiMap: Record<string, CustomEmoji>) => emojify(text, emojiMap);
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 => {
if (oldStatus && oldStatus.content === status.content && oldStatus.spoiler_text === status.spoiler_text) {