11import React , { useEffect , useRef } from 'react' ;
22import { ActorProperties } from '@tryghost/admin-x-framework/api/activitypub' ;
33import { Button , LoadingIndicator , Skeleton } from '@tryghost/shade/components' ;
4- import { LucideIcon } from '@tryghost/shade/utils' ;
4+ import { LucideIcon , formatNumber } from '@tryghost/shade/utils' ;
55
66import APAvatar from '@components/global/ap-avatar' ;
77import AppError from '@components/layout/error' ;
@@ -113,6 +113,7 @@ function groupNotifications(notifications: Notification[]): NotificationGroup[]
113113const 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
@@ -372,7 +375,9 @@ const Notifications: React.FC = () => {
372375 className = 'group/item break-anywhere flex items-center justify-between gap-4'
373376 onClick = { ( e ) => {
374377 e ?. stopPropagation ( ) ;
375- handleProfileClick ( actor . handle , navigate ) ;
378+ if ( actor . handle ) {
379+ handleProfileClick ( actor . handle , navigate ) ;
380+ }
376381 } }
377382 >
378383 < div className = 'flex min-w-0 items-center' >
@@ -386,7 +391,7 @@ const Notifications: React.FC = () => {
386391 < span className = 'ml-2 line-clamp-1 text-base font-semibold group-hover/item:underline dark:text-white' > { actor . name } </ span >
387392 < span className = 'ml-1 line-clamp-1 text-base text-gray-700 dark:text-gray-600' > { actor . handle } </ span >
388393 </ div >
389- { group . type === 'follow' && ! actor . followedByMe && (
394+ { group . type === 'follow' && ! actor . followedByMe && actor . handle && (
390395 < FollowButton
391396 following = { false }
392397 handle = { actor . handle }
@@ -418,7 +423,7 @@ const Notifications: React.FC = () => {
418423 }
419424 </ div >
420425 { /* Follow button for singular follow, reply, and mention */ }
421- { group . actors . length === 1 && ( group . type === 'follow' || group . type === 'reply' || group . type === 'mention' ) && ! group . actors [ 0 ] . followedByMe && (
426+ { group . actors . length === 1 && ( group . type === 'follow' || group . type === 'reply' || group . type === 'mention' ) && ! group . actors [ 0 ] . followedByMe && group . actors [ 0 ] . handle && (
422427 < FollowButton
423428 following = { false }
424429 handle = { group . actors [ 0 ] . handle }
0 commit comments