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
0 commit comments