0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-17 23:44:39 -05:00

Added repost count on ActivityPub UI (#22116)

Ref https://linear.app/ghost/issue/AP-706/

- This is for showing the count on the UI for number of times a post has
been reposted.
This commit is contained in:
Princi Vershwal 2025-02-06 10:36:36 +05:30 committed by GitHub
parent 1b2e121165
commit d9d52fdd77
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 16 additions and 1 deletions

View file

@ -118,6 +118,7 @@ const Inbox: React.FC<InboxProps> = ({layout}) => {
commentCount={activity.object.replyCount ?? 0}
layout={layout}
object={activity.object}
repostCount={activity.object.repostCount ?? 0}
type={activity.type}
onClick={() => handleViewContent(activity, false, updateActivity)}
onCommentClick={() => handleViewContent(activity, true, updateActivity)}

View file

@ -845,6 +845,7 @@ const ArticleModal: React.FC<ArticleModalProps> = ({
last={false}
layout='reply'
object={item.object}
repostCount={item.object.repostCount ?? 0}
type='Note'
onClick={() => {
navigateForward(item.id, item.object, item.actor, false);
@ -864,6 +865,7 @@ const ArticleModal: React.FC<ArticleModalProps> = ({
last={true}
layout={'modal'}
object={object}
repostCount={object.repostCount ?? 0}
showHeader={(canNavigateBack || (activityThreadParents.length > 0))}
type='Note'
onCommentClick={() => {
@ -894,6 +896,7 @@ const ArticleModal: React.FC<ArticleModalProps> = ({
layout={'modal'}
likeCount={1}
object={object}
repostCount={object.repostCount ?? 0}
onCommentClick={() => {
repliesRef.current?.scrollIntoView({
behavior: 'smooth',
@ -929,6 +932,7 @@ const ArticleModal: React.FC<ArticleModalProps> = ({
last={true}
layout='reply'
object={item.object}
repostCount={item.object.repostCount ?? 0}
type='Note'
onClick={() => {
navigateForward(item.id, item.object, item.actor, false);

View file

@ -148,6 +148,7 @@ interface FeedItemProps {
layout: string;
type: string;
commentCount?: number;
repostCount?: number;
showHeader?: boolean;
last?: boolean;
onClick?: () => void;
@ -156,7 +157,7 @@ interface FeedItemProps {
const noop = () => {};
const FeedItem: React.FC<FeedItemProps> = ({actor, object, layout, type, commentCount = 0, showHeader = true, last, onClick: onClickHandler = noop, onCommentClick}) => {
const FeedItem: React.FC<FeedItemProps> = ({actor, object, layout, type, commentCount = 0, repostCount = 0, showHeader = true, last, onClick: onClickHandler = noop, onCommentClick}) => {
const timestamp =
new Date(object?.published ?? new Date()).toLocaleDateString('default', {year: 'numeric', month: 'short', day: '2-digit'}) + ', ' + new Date(object?.published ?? new Date()).toLocaleTimeString('default', {hour: '2-digit', minute: '2-digit'});
@ -294,6 +295,7 @@ const FeedItem: React.FC<FeedItemProps> = ({actor, object, layout, type, comment
layout={layout}
likeCount={1}
object={object}
repostCount={repostCount}
onCommentClick={onCommentClick}
onLikeClick={onLikeClick}
/>
@ -335,6 +337,7 @@ const FeedItem: React.FC<FeedItemProps> = ({actor, object, layout, type, comment
layout={layout}
likeCount={1}
object={object}
repostCount={repostCount}
onCommentClick={onCommentClick}
onLikeClick={onLikeClick}
/>
@ -393,6 +396,7 @@ const FeedItem: React.FC<FeedItemProps> = ({actor, object, layout, type, comment
layout={layout}
likeCount={1}
object={object}
repostCount={repostCount}
onCommentClick={onCommentClick}
onLikeClick={onLikeClick}
/>
@ -442,6 +446,7 @@ const FeedItem: React.FC<FeedItemProps> = ({actor, object, layout, type, comment
layout={layout}
likeCount={1}
object={object}
repostCount={repostCount}
onCommentClick={onCommentClick}
onLikeClick={onLikeClick}
/>

View file

@ -7,6 +7,7 @@ interface FeedItemStatsProps {
object: ObjectProperties;
likeCount: number;
commentCount: number;
repostCount: number;
layout: string;
onLikeClick: () => void;
onCommentClick: () => void;
@ -16,6 +17,7 @@ const FeedItemStats: React.FC<FeedItemStatsProps> = ({
object,
likeCount,
commentCount,
repostCount,
layout,
onLikeClick,
onCommentClick
@ -74,9 +76,11 @@ const FeedItemStats: React.FC<FeedItemStatsProps> = ({
/>
<Button
className={buttonClassName}
hideLabel={repostCount === 0 || (layout === 'inbox')}
icon='reload'
iconColorClass={`w-[18px] h-[18px] ${isReposted && 'text-green'}`}
id='repost'
label={new Intl.NumberFormat().format(repostCount)}
size='md'
title='Repost'
unstyled={true}

View file

@ -173,6 +173,7 @@ const PostsTab: React.FC<{handle: string}> = ({handle}) => {
commentCount={post.object.replyCount}
layout='feed'
object={post.object}
repostCount={post.object.repostCount}
type={post.type}
onClick={() => handleViewContent(post, false)}
onCommentClick={() => handleViewContent(post, true)}