Add quotes_count to statuses stats (#35832)

This commit is contained in:
Claire 2025-08-25 14:21:28 +02:00 committed by GitHub
parent 94ad088482
commit 2560242972
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 94 additions and 9 deletions

View file

@ -96,6 +96,7 @@ export interface ApiStatusJSON {
replies_count: number;
reblogs_count: number;
favorites_count: number;
quotes_count: number;
edited_at?: string;
favorited?: boolean;

View file

@ -160,7 +160,12 @@ export const StatusReblogButton: FC<ReblogButtonProps> = ({
)}
icon='retweet'
iconComponent={iconComponent}
counter={counters ? (status.get('reblogs_count') as number) : undefined}
counter={
counters
? (status.get('reblogs_count') as number) +
(status.get('quotes_count') as number)
: undefined
}
active={isReblogged}
/>
</Dropdown>
@ -283,7 +288,12 @@ export const LegacyReblogButton: FC<ReblogButtonProps> = ({
icon='retweet'
iconComponent={iconComponent}
onClick={!disabled ? handleClick : undefined}
counter={counters ? (status.get('reblogs_count') as number) : undefined}
counter={
counters
? (status.get('reblogs_count') as number) +
(status.get('quotes_count') as number)
: undefined
}
/>
);
};

View file

@ -233,7 +233,10 @@ export const Footer: React.FC<{
icon='retweet'
iconComponent={reblogIconComponent}
onClick={handleReblogClick}
counter={status.get('reblogs_count') as number}
counter={
(status.get('reblogs_count') as number) +
(status.get('quotes_count') as number)
}
/>
<IconButton

View file

@ -127,6 +127,7 @@ export const DetailedStatus: React.FC<{
let media;
let applicationLink;
let reblogLink;
let quotesLink;
let attachmentAspectRatio;
if (properStatus.get('media_attachments').getIn([0, 'type']) === 'video') {
@ -279,6 +280,23 @@ export const DetailedStatus: React.FC<{
);
}
if (['private', 'direct'].includes(status.get('visibility') as string)) {
quotesLink = '';
} else {
quotesLink = (
<span className='detailed-status__link'>
<span className='detailed-status__quotes'>
<AnimatedNumber value={status.get('quotes_count')} />
</span>
<FormattedMessage
id='status.quotes'
defaultMessage='{count, plural, one {quote} other {quotes}}'
values={{ count: status.get('quotes_count') }}
/>
</span>
);
}
const favouriteLink = (
<Link
to={`/@${status.getIn(['account', 'acct'])}/${status.get('id')}/favourites`}
@ -420,6 +438,8 @@ export const DetailedStatus: React.FC<{
<div className='detailed-status__meta__line'>
{reblogLink}
{reblogLink && <>·</>}
{quotesLink}
{quotesLink && <>·</>}
{favouriteLink}
</div>
</div>

View file

@ -900,6 +900,7 @@
"status.quote_policy_change": "Change who can quote",
"status.quote_post_author": "Quoted a post by @{name}",
"status.quote_private": "Private posts cannot be quoted",
"status.quotes": "{count, plural, one {quote} other {quotes}}",
"status.read_more": "Read more",
"status.reblog": "Boost",
"status.reblog_private": "Boost with original visibility",

View file

@ -68,6 +68,7 @@ export const statusFactory: FactoryFunction<ApiStatusJSON> = ({
url: 'https://example.com/status/1',
replies_count: 0,
reblogs_count: 0,
quotes_count: 0,
favorites_count: 0,
account: accountFactory(),
media_attachments: [],