Skip to content

Commit 6c3b460

Browse files
Fixed the other CodeRabbit suggestion
no ref Guarded notification profile navigation before calling handleProfileClick because notification actors can arrive without a handle at runtime even though the local type currently marks it as required. Also formatted the visible notification actor counts after touching the TSX file.
1 parent bb40e3b commit 6c3b460

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

apps/activitypub/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tryghost/activitypub",
3-
"version": "3.1.38",
3+
"version": "3.1.39",
44
"license": "MIT",
55
"repository": {
66
"type": "git",

apps/activitypub/src/views/notifications/notifications.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, {useEffect, useRef} from 'react';
22
import {ActorProperties} from '@tryghost/admin-x-framework/api/activitypub';
33
import {Button, LoadingIndicator, Skeleton} from '@tryghost/shade/components';
4-
import {LucideIcon} from '@tryghost/shade/utils';
4+
import {LucideIcon, formatNumber} from '@tryghost/shade/utils';
55

66
import APAvatar from '@components/global/ap-avatar';
77
import AppError from '@components/layout/error';
@@ -113,6 +113,7 @@ function groupNotifications(notifications: Notification[]): NotificationGroup[]
113113
const NotificationGroupDescription: React.FC<NotificationGroupDescriptionProps> = ({group}) => {
114114
const [firstActor, ...otherActors] = group.actors;
115115
const hasOthers = otherActors.length > 0;
116+
const otherActorsCount = otherActors.length;
116117

117118
const actorClass = 'cursor-pointer font-semibold hover:underline text-black dark:text-white';
118119

@@ -125,13 +126,15 @@ const NotificationGroupDescription: React.FC<NotificationGroupDescriptionProps>
125126
className={actorClass}
126127
onClick={(e) => {
127128
e?.stopPropagation();
128-
handleProfileClick(firstActor.handle, navigate);
129+
if (firstActor.handle) {
130+
handleProfileClick(firstActor.handle, navigate);
131+
}
129132
}}
130133
>
131134
{firstActor.name}
132135
</span>
133136
</ProfilePreviewHoverCard>
134-
{hasOthers && ` and ${otherActors.length} ${otherActors.length > 1 ? 'others' : 'other'}`}
137+
{hasOthers && ` and ${formatNumber(otherActorsCount)} ${otherActorsCount > 1 ? 'others' : 'other'}`}
135138
</>
136139
);
137140

@@ -271,7 +274,7 @@ const Notifications: React.FC = () => {
271274
case 'follow':
272275
if (group.actors.length > 1) {
273276
toggleOpen(group.id || `${group.type}_${index}`);
274-
} else {
277+
} else if (group.actors[0]?.handle) {
275278
handleProfileClick(group.actors[0].handle, navigate);
276279
}
277280
break;
@@ -349,7 +352,7 @@ const Notifications: React.FC = () => {
349352
))}
350353
{group.actors.length > maxAvatars && (!openStates[group.id || `${group.type}_${index}`]) && (
351354
<div className='absolute right-[28px] z-10 flex size-9 items-center justify-center rounded-full bg-black/50 text-base font-semibold tracking-tightest text-white'>
352-
{`+${group.actors.length - maxAvatars}`}
355+
{`+${formatNumber(group.actors.length - maxAvatars)}`}
353356
</div>
354357
)}
355358

0 commit comments

Comments
 (0)