From 2ab618709a6617995ee0ce70fb4f4838593f6318 Mon Sep 17 00:00:00 2001 From: Djordje Vlaisavljevic Date: Mon, 23 Sep 2024 20:21:35 +0100 Subject: [PATCH] Linked timestamps to original post URLs for easier navigation ref https://linear.app/tryghost/issue/AP-408/add-link-to-original-post-location-in-ui-for-better-navigation --- .../src/components/feed/FeedItem.tsx | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/apps/admin-x-activitypub/src/components/feed/FeedItem.tsx b/apps/admin-x-activitypub/src/components/feed/FeedItem.tsx index 6d31f31176..fcce46f74c 100644 --- a/apps/admin-x-activitypub/src/components/feed/FeedItem.tsx +++ b/apps/admin-x-activitypub/src/components/feed/FeedItem.tsx @@ -137,6 +137,14 @@ function renderInboxAttachment(object: ObjectProperties) { } } +function renderTimestamp(object: ObjectProperties) { + 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'}); + + const date = new Date(object?.published ?? new Date()); + return ({getRelativeTimestamp(date)}); +} + const FeedItemStats: React.FC<{ object: ObjectProperties; likeCount: number; @@ -217,6 +225,7 @@ const FeedItem: React.FC = ({actor, object, layout, type, comment 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'}); const date = new Date(object?.published ?? new Date()); + const [isCopied, setIsCopied] = useState(false); const onLikeClick = () => { @@ -291,7 +300,7 @@ const FeedItem: React.FC = ({actor, object, layout, type, comment {author.name} {getUsername(author)} - {getRelativeTimestamp(date)} + {renderTimestamp(object)} @@ -338,8 +347,8 @@ const FeedItem: React.FC = ({actor, object, layout, type, comment {/*
*/}
- {author.name} - {getRelativeTimestamp(date)} + {author.name} + {renderTimestamp(object)}
{getUsername(author)} @@ -385,11 +394,10 @@ const FeedItem: React.FC = ({actor, object, layout, type, comment
- {/*
*/}
- {author.name} - {getRelativeTimestamp(date)} + {author.name} + {renderTimestamp(object)}
{getUsername(author)} @@ -412,7 +420,6 @@ const FeedItem: React.FC = ({actor, object, layout, type, comment
- {/*
*/}
{!last &&
}