[Glitch] Change `author_account` to be `authors` in REST API
Port 096057b845
to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
parent
d612daee97
commit
4179f5fcf3
|
@ -76,8 +76,8 @@ export function importFetchedStatuses(statuses) {
|
||||||
pushUnique(polls, normalizePoll(status.poll, getState().getIn(['polls', status.poll.id])));
|
pushUnique(polls, normalizePoll(status.poll, getState().getIn(['polls', status.poll.id])));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status.card?.author_account) {
|
if (status.card) {
|
||||||
pushUnique(accounts, status.card.author_account);
|
status.card.authors.forEach(author => author.account && pushUnique(accounts, author.account));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,15 @@ export function normalizeStatus(status, normalOldStatus, settings) {
|
||||||
normalStatus.poll = status.poll.id;
|
normalStatus.poll = status.poll.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status.card?.author_account) {
|
if (status.card) {
|
||||||
normalStatus.card = { ...status.card, author_account: status.card.author_account.id };
|
normalStatus.card = {
|
||||||
|
...status.card,
|
||||||
|
authors: status.card.authors.map(author => ({
|
||||||
|
...author,
|
||||||
|
accountId: author.account?.id,
|
||||||
|
account: undefined,
|
||||||
|
})),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status.filtered) {
|
if (status.filtered) {
|
||||||
|
|
|
@ -51,7 +51,7 @@ export const fetchTrendingLinks = () => (dispatch) => {
|
||||||
api()
|
api()
|
||||||
.get('/api/v1/trends/links', { params: { limit: 20 } })
|
.get('/api/v1/trends/links', { params: { limit: 20 } })
|
||||||
.then(({ data }) => {
|
.then(({ data }) => {
|
||||||
dispatch(importFetchedAccounts(data.map(link => link.author_account).filter(account => !!account)));
|
dispatch(importFetchedAccounts(data.flatMap(link => link.authors.map(author => author.account)).filter(account => !!account)));
|
||||||
dispatch(fetchTrendingLinksSuccess(data));
|
dispatch(fetchTrendingLinksSuccess(data));
|
||||||
})
|
})
|
||||||
.catch(err => dispatch(fetchTrendingLinksFail(err)));
|
.catch(err => dispatch(fetchTrendingLinksFail(err)));
|
||||||
|
|
|
@ -30,6 +30,12 @@ export interface ApiMentionJSON {
|
||||||
acct: string;
|
acct: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ApiPreviewCardAuthorJSON {
|
||||||
|
name: string;
|
||||||
|
url: string;
|
||||||
|
account?: ApiAccountJSON;
|
||||||
|
}
|
||||||
|
|
||||||
export interface ApiPreviewCardJSON {
|
export interface ApiPreviewCardJSON {
|
||||||
url: string;
|
url: string;
|
||||||
title: string;
|
title: string;
|
||||||
|
@ -48,6 +54,7 @@ export interface ApiPreviewCardJSON {
|
||||||
embed_url: string;
|
embed_url: string;
|
||||||
blurhash: string;
|
blurhash: string;
|
||||||
published_at: string;
|
published_at: string;
|
||||||
|
authors: ApiPreviewCardAuthorJSON[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ApiStatusJSON {
|
export interface ApiStatusJSON {
|
||||||
|
|
|
@ -7,6 +7,10 @@ import { useAppSelector } from 'flavours/glitch/store';
|
||||||
export const AuthorLink = ({ accountId }) => {
|
export const AuthorLink = ({ accountId }) => {
|
||||||
const account = useAppSelector(state => state.getIn(['accounts', accountId]));
|
const account = useAppSelector(state => state.getIn(['accounts', accountId]));
|
||||||
|
|
||||||
|
if (!account) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Permalink href={account.get('url')} to={`/@${account.get('acct')}`} className='story__details__shared__author-link'>
|
<Permalink href={account.get('url')} to={`/@${account.get('acct')}`} className='story__details__shared__author-link'>
|
||||||
<Avatar account={account} size={16} />
|
<Avatar account={account} size={16} />
|
||||||
|
|
|
@ -75,7 +75,7 @@ class Links extends PureComponent {
|
||||||
publisher={link.get('provider_name')}
|
publisher={link.get('provider_name')}
|
||||||
publishedAt={link.get('published_at')}
|
publishedAt={link.get('published_at')}
|
||||||
author={link.get('author_name')}
|
author={link.get('author_name')}
|
||||||
authorAccount={link.getIn(['author_account', 'id'])}
|
authorAccount={link.getIn(['authors', 0, 'account', 'id'])}
|
||||||
sharedTimes={link.getIn(['history', 0, 'accounts']) * 1 + link.getIn(['history', 1, 'accounts']) * 1}
|
sharedTimes={link.getIn(['history', 0, 'accounts']) * 1 + link.getIn(['history', 1, 'accounts']) * 1}
|
||||||
thumbnail={link.get('image')}
|
thumbnail={link.get('image')}
|
||||||
thumbnailDescription={link.get('image_description')}
|
thumbnailDescription={link.get('image_description')}
|
||||||
|
|
|
@ -127,7 +127,7 @@ export default class Card extends PureComponent {
|
||||||
const interactive = card.get('type') === 'video';
|
const interactive = card.get('type') === 'video';
|
||||||
const language = card.get('language') || '';
|
const language = card.get('language') || '';
|
||||||
const largeImage = (card.get('image')?.length > 0 && card.get('width') > card.get('height')) || interactive;
|
const largeImage = (card.get('image')?.length > 0 && card.get('width') > card.get('height')) || interactive;
|
||||||
const showAuthor = !!card.get('author_account');
|
const showAuthor = !!card.getIn(['authors', 0, 'accountId']);
|
||||||
|
|
||||||
const description = (
|
const description = (
|
||||||
<div className='status-card__content'>
|
<div className='status-card__content'>
|
||||||
|
@ -233,7 +233,7 @@ export default class Card extends PureComponent {
|
||||||
{description}
|
{description}
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
{showAuthor && <MoreFromAuthor accountId={card.get('author_account')} />}
|
{showAuthor && <MoreFromAuthor accountId={card.getIn(['authors', 0, 'accountId'])} />}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue