From f214213859301585e544922c29def3f8cbf1f219 Mon Sep 17 00:00:00 2001 From: Djordje Vlaisavljevic Date: Tue, 22 Oct 2024 15:40:01 +0100 Subject: [PATCH] Improved how we handle `Like` notifications ref https://linear.app/ghost/issue/AP-480/handle-likes-received-on-replies - Clicking a notification now opens Article/Note in the drawer - When the liked post is a reply, the content of the reply is shown in the notification --- .../src/components/Activities.tsx | 36 +++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/apps/admin-x-activitypub/src/components/Activities.tsx b/apps/admin-x-activitypub/src/components/Activities.tsx index 249d20940d..ebff8a7d6f 100644 --- a/apps/admin-x-activitypub/src/components/Activities.tsx +++ b/apps/admin-x-activitypub/src/components/Activities.tsx @@ -33,8 +33,10 @@ const getActivityDescription = (activity: Activity): string => { case ACTVITY_TYPE.FOLLOW: return 'Followed you'; case ACTVITY_TYPE.LIKE: - if (activity.object) { + if (activity.object && activity.object.type === 'Article') { return `Liked your article "${activity.object.name}"`; + } else if (activity.object && activity.object.type === 'Note') { + return `${activity.object.content}`; } } @@ -136,6 +138,28 @@ const Activities: React.FC = ({}) => { // return followers.includes(id); // }; + const handleActivityClick = (activity: Activity) => { + switch (activity.type) { + case ACTVITY_TYPE.CREATE: + NiceModal.show(ArticleModal, { + object: activity.object, + actor: activity.actor, + comments: activity.object.replies + }); + break; + case ACTVITY_TYPE.LIKE: + NiceModal.show(ArticleModal, { + object: activity.object, + actor: activity.actor, + comments: activity.object.replies + }); + break; + case ACTVITY_TYPE.FOLLOW: + break; + default: + } + }; + return ( <> @@ -162,15 +186,7 @@ const Activities: React.FC = ({}) => { { - NiceModal.show(ArticleModal, { - object: activity.object, - actor: activity.actor, - comments: activity.object.replies - }); - } : undefined - } + onClick={() => handleActivityClick(activity)} >