diff --git a/apps/admin-x-activitypub/src/components/Inbox.tsx b/apps/admin-x-activitypub/src/components/Inbox.tsx index f4256444df..0f7e17441d 100644 --- a/apps/admin-x-activitypub/src/components/Inbox.tsx +++ b/apps/admin-x-activitypub/src/components/Inbox.tsx @@ -27,7 +27,8 @@ const Inbox: React.FC = ({}) => { setArticleContent(object); setArticleActor(actor); NiceModal.show(ArticleModal, { - object: object + object: object, + actor: actor }); }; diff --git a/apps/admin-x-activitypub/src/components/feed/ArticleModal.tsx b/apps/admin-x-activitypub/src/components/feed/ArticleModal.tsx index 9da2d3f10f..0826217767 100644 --- a/apps/admin-x-activitypub/src/components/feed/ArticleModal.tsx +++ b/apps/admin-x-activitypub/src/components/feed/ArticleModal.tsx @@ -1,14 +1,15 @@ +import FeedItem from './FeedItem'; import MainHeader from '../navigation/MainHeader'; import NiceModal, {useModal} from '@ebay/nice-modal-react'; import React, {useEffect, useRef} from 'react'; import articleBodyStyles from '../articleBodyStyles'; +import {ActorProperties, ObjectProperties} from '@tryghost/admin-x-framework/api/activitypub'; import {Button, Modal} from '@tryghost/admin-x-design-system'; -import {ObjectProperties} from '@tryghost/admin-x-framework/api/activitypub'; -import {renderAttachment} from './FeedItem'; import {useBrowseSite} from '@tryghost/admin-x-framework/api/site'; interface ArticleModalProps { object: ObjectProperties; + actor: ActorProperties; } const ArticleBody: React.FC<{heading: string, image: string|undefined, html: string}> = ({heading, image, html}) => { @@ -62,7 +63,7 @@ ${image && ); }; -const ArticleModal: React.FC = ({object}) => { +const ArticleModal: React.FC = ({object, actor}) => { const modal = useModal(); return ( = ({object}) => {
{object.type === 'Note' && (
- {object.content &&
} - {renderAttachment(object)} + + {/* {object.content &&
} */} + {/* {renderAttachment(object)} */}
)} {object.type === 'Article' && }
diff --git a/apps/admin-x-activitypub/src/components/feed/FeedItem.tsx b/apps/admin-x-activitypub/src/components/feed/FeedItem.tsx index e35f2edd64..7a5168d767 100644 --- a/apps/admin-x-activitypub/src/components/feed/FeedItem.tsx +++ b/apps/admin-x-activitypub/src/components/feed/FeedItem.tsx @@ -5,7 +5,7 @@ import getUsername from '../../utils/get-username'; import {ActorProperties, ObjectProperties} from '@tryghost/admin-x-framework/api/activitypub'; import {Button, Heading, Icon} from '@tryghost/admin-x-design-system'; -export function renderAttachment(object: ObjectProperties) { +export function renderAttachment(object: ObjectProperties, layout: string) { let attachment; if (object.image) { attachment = object.image; @@ -23,16 +23,16 @@ export function renderAttachment(object: ObjectProperties) { const attachmentCount = attachment.length; let gridClass = ''; - if (attachmentCount === 1) { + if (layout === 'modal') { gridClass = 'grid-cols-1'; // Single image, full width } else if (attachmentCount === 2) { - gridClass = 'grid-cols-2'; // Two images, side by side + gridClass = 'grid-cols-2 auto-rows-[150px]'; // Two images, side by side } else if (attachmentCount === 3 || attachmentCount === 4) { - gridClass = 'grid-cols-2'; // Three or four images, two per row + gridClass = 'grid-cols-2 auto-rows-[150px]'; // Three or four images, two per row } return ( -
+
{attachment.map((item, index) => ( {`attachment-${index}`} ))} @@ -48,7 +48,7 @@ export function renderAttachment(object: ObjectProperties) { case 'video/mp4': case 'video/webm': return
-
; case 'audio/mpeg': @@ -69,18 +69,6 @@ interface FeedItemProps { } const FeedItem: React.FC = ({actor, object, layout, type}) => { - const parser = new DOMParser(); - const doc = parser.parseFromString(object.content || '', 'text/html'); - - const plainTextContent = doc.body.textContent; - let previewContent = ''; - if (object.preview) { - const previewDoc = parser.parseFromString(object.preview.content || '', 'text/html'); - previewContent = previewDoc.body.textContent || ''; - } else if (object.type === 'Note') { - previewContent = plainTextContent || ''; - } - 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'}); @@ -101,79 +89,47 @@ const FeedItem: React.FC = ({actor, object, layout, type}) => { author = typeof object.attributedTo === 'object' ? object.attributedTo as ActorProperties : actor; } - if (layout === 'feed') { - return ( - <> - {object && ( -
- {(type === 'Announce' && object.type === 'Note') &&
-
- {actor.name} reposted -
} -
- -
-
-
- {author.name} - {getRelativeTimestamp(date)} -
-
- {getUsername(author)} -
-
-
-
- {object.name && {object.name}} -
- {/*

{object.content}

*/} - {renderAttachment(object)} -
-
-
-
+ return ( + <> + {object && ( +
+ {(type === 'Announce' && object.type === 'Note') &&
+
+ {actor.name} reposted +
} +
+
+ +
+ {/*
*/} +
+
+ {author.name} + {getRelativeTimestamp(date)} +
+
+ {getUsername(author)}
-
-
- )} - - ); - } else if (layout === 'inbox') { - return ( - <> - {object && ( -
-
- - {actor.name} - {/* {getUsername(actor)} */} - {timestamp} -
-
+
-
- {object.name} -
-

{previewContent}

-
+ {object.name && {object.name}} +
+ {/*

{object.content}

*/} + {renderAttachment(object, layout)} +
- {/* {image &&
- -
} */}
-
- {/*
*/} + {/*
*/}
- )} - - ); - } +
+
+ )} + + ); }; export default FeedItem; \ No newline at end of file