mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Added nested comment rendering in admin-x-activitypub app (#20980)
refs [AP-279](https://linear.app/tryghost/issue/AP-279/handle-incoming-replies) Added nested comment rendering in admin-x-activitypub app so that replies to posts and replies to replies can be viewed by the user
This commit is contained in:
parent
ba74785250
commit
2fc6634573
2 changed files with 38 additions and 12 deletions
|
@ -50,7 +50,7 @@ const Inbox: React.FC<InboxProps> = ({}) => {
|
|||
const handleViewContent = (object: ObjectProperties, actor: ActorProperties, comments: Activity[]) => {
|
||||
setArticleContent(object);
|
||||
setArticleActor(actor);
|
||||
NiceModal.show(ArticleModal, {object, actor, comments});
|
||||
NiceModal.show(ArticleModal, {object, actor, comments, allComments: commentsMap});
|
||||
};
|
||||
|
||||
const handleLayoutChange = (newLayout: string) => {
|
||||
|
|
|
@ -15,6 +15,7 @@ interface ArticleModalProps {
|
|||
object: ObjectProperties;
|
||||
actor: ActorProperties;
|
||||
comments: Activity[];
|
||||
allComments: Map<string, Activity[]>;
|
||||
}
|
||||
|
||||
const ArticleBody: React.FC<{heading: string, image: string|undefined, html: string}> = ({heading, image, html}) => {
|
||||
|
@ -68,7 +69,11 @@ ${image &&
|
|||
);
|
||||
};
|
||||
|
||||
const ArticleModal: React.FC<ArticleModalProps> = ({object, actor, comments}) => {
|
||||
const FeedItemDivider: React.FC = () => (
|
||||
<div className="mx-[-32px] my-4 h-px w-[120%] bg-grey-200"></div>
|
||||
);
|
||||
|
||||
const ArticleModal: React.FC<ArticleModalProps> = ({object, actor, comments, allComments}) => {
|
||||
const modal = useModal();
|
||||
return (
|
||||
<Modal
|
||||
|
@ -109,16 +114,37 @@ const ArticleModal: React.FC<ArticleModalProps> = ({object, actor, comments}) =>
|
|||
<FeedItem actor={actor} last={false} layout='reply' object={object} type='Note'/>
|
||||
<FeedItem actor={actor} last={false} layout='reply' object={object} type='Note'/>
|
||||
<FeedItem actor={actor} last={true} layout='reply' object={object} type='Note'/> */}
|
||||
{comments.map((comment, index) => (
|
||||
<FeedItem
|
||||
actor={comment.actor}
|
||||
last={index === comments.length - 1}
|
||||
layout='reply'
|
||||
object={comment.object}
|
||||
type='Note'
|
||||
/>
|
||||
))}
|
||||
</div>)}
|
||||
{comments.map((comment, index) => {
|
||||
const showDivider = index !== comments.length - 1;
|
||||
const nestedComments = allComments.get(comment.object.id) ?? [];
|
||||
const hasNestedComments = nestedComments.length > 0;
|
||||
|
||||
return (
|
||||
<>
|
||||
<FeedItem
|
||||
actor={comment.actor}
|
||||
comments={nestedComments}
|
||||
last={true}
|
||||
layout='reply'
|
||||
object={comment.object}
|
||||
type='Note'
|
||||
/>
|
||||
{hasNestedComments && <FeedItemDivider />}
|
||||
{nestedComments.map((nestedComment, nestedCommentIndex) => (
|
||||
<FeedItem
|
||||
actor={nestedComment.actor}
|
||||
last={nestedComments.length === nestedCommentIndex + 1}
|
||||
layout='reply'
|
||||
object={nestedComment.object}
|
||||
type='Note'
|
||||
/>
|
||||
))}
|
||||
{showDivider && <FeedItemDivider />}
|
||||
</>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
{object.type === 'Article' && (
|
||||
<ArticleBody heading={object.name} html={object.content} image={object?.image} />
|
||||
)}
|
||||
|
|
Loading…
Add table
Reference in a new issue