Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added repost count on ActivityPub API #22116

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/admin-x-activitypub/src/components/Inbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
Expand Down
4 changes: 4 additions & 0 deletions apps/admin-x-activitypub/src/components/feed/ArticleModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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={() => {
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 6 additions & 1 deletion apps/admin-x-activitypub/src/components/feed/FeedItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ interface FeedItemProps {
layout: string;
type: string;
commentCount?: number;
repostCount?: number;
showHeader?: boolean;
last?: boolean;
onClick?: () => void;
Expand All @@ -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'});

Expand Down Expand Up @@ -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}
/>
Expand Down Expand Up @@ -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}
/>
Expand Down Expand Up @@ -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}
/>
Expand Down Expand Up @@ -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}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ interface FeedItemStatsProps {
object: ObjectProperties;
likeCount: number;
commentCount: number;
repostCount: number;
layout: string;
onLikeClick: () => void;
onCommentClick: () => void;
Expand All @@ -16,6 +17,7 @@ const FeedItemStats: React.FC<FeedItemStatsProps> = ({
object,
likeCount,
commentCount,
repostCount,
layout,
onLikeClick,
onCommentClick
Expand Down Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
Expand Down
Loading