Migrate to external library for interacting with API

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak
2024-08-06 19:52:36 +02:00
parent 3b87810f85
commit 32c68a9221
89 changed files with 364 additions and 710 deletions

View File

@ -7,14 +7,14 @@ import { shortNumberFormat } from '../utils/numbers';
import { HStack, Stack, Text } from './ui';
import type { Tag } from 'soapbox/types/entities';
import type { Tag } from 'pl-api';
interface IHashtag {
hashtag: Tag;
}
const Hashtag: React.FC<IHashtag> = ({ hashtag }) => {
const count = Number(hashtag.history?.get(0)?.accounts);
const count = Number(hashtag.history?.[0]?.accounts);
return (
<HStack alignItems='center' justifyContent='between' data-testid='hashtag'>
@ -42,7 +42,7 @@ const Hashtag: React.FC<IHashtag> = ({ hashtag }) => {
<Sparklines
width={40}
height={28}
data={hashtag.history.reverse().map((day) => +day.uses).toArray()}
data={hashtag.history.reverse().map((day) => +day.uses)}
>
<SparklinesCurve style={{ fill: 'none' }} color='#818cf8' />
</Sparklines>

View File

@ -278,7 +278,7 @@ const StatusActionBar: React.FC<IStatusActionBar> = ({
const account = status.account;
getOrCreateChatByAccountId(account.id)
.then(({ json: chat }) => history.push(`/chats/${chat.id}`))
.then((chat) => history.push(`/chats/${chat.id}`))
.catch(() => {});
};
@ -429,7 +429,7 @@ const StatusActionBar: React.FC<IStatusActionBar> = ({
if (features.bookmarkFolders && fromBookmarks) {
menu.push({
text: intl.formatMessage(status.pleroma.get('bookmark_folder') ? messages.bookmarkChangeFolder : messages.bookmarkSetFolder),
text: intl.formatMessage(status.bookmark_folder ? messages.bookmarkChangeFolder : messages.bookmarkSetFolder),
action: handleBookmarkFolderClick,
icon: require('@tabler/icons/outline/folders.svg'),
});

View File

@ -361,7 +361,7 @@ const Status: React.FC<IStatus> = (props) => {
let quote;
if (actualStatus.quote) {
if (actualStatus.pleroma.get('quote_visible', true) === false) {
if ((actualStatus.quote_visible ?? true) === false) {
quote = (
<div className='quoted-status-tombstone'>
<p><FormattedMessage id='statuses.quote_tombstone' defaultMessage='Post is unavailable.' /></p>