@@ -53,12 +53,10 @@ interface IAvatarPosition {
5353}
5454
5555function determineAvatarPosition ( index : number , count : number , max : number ) : IAvatarPosition {
56- const firstVisible = Math . max ( 0 , count - max ) ;
57-
58- if ( index >= firstVisible ) {
56+ if ( index < max ) {
5957 return {
6058 hidden : false ,
61- position : index - firstVisible ,
59+ position : Math . min ( count , max ) - index ,
6260 } ;
6361 } else {
6462 return {
@@ -72,8 +70,42 @@ export function ReadReceiptGroup(
7270 { readReceipts, readReceiptMap, checkUnmounting, suppressAnimation, isTwelveHour } : Props ,
7371) {
7472 const [ menuDisplayed , button , openMenu , closeMenu ] = useContextMenu ( ) ;
73+
74+ // If we are above MAX_READ_AVATARS, we’ll have to remove a few to have space for the +n count.
75+ const maxAvatars = readReceipts . length > MAX_READ_AVATARS
76+ ? MAX_READ_AVATARS_PLUS_N
77+ : MAX_READ_AVATARS ;
78+
79+ const tooltipMembers : string [ ] = readReceipts . slice ( 0 , maxAvatars )
80+ . map ( it => it . roomMember ?. name ?? it . userId ) ;
81+ let tooltipText : string | null ;
82+ if ( readReceipts . length > MAX_READ_AVATARS ) {
83+ tooltipText = _t ( "%(members)s and more" , {
84+ members : tooltipMembers . join ( ", " ) ,
85+ } ) ;
86+ } else if ( readReceipts . length ) {
87+ const last = tooltipMembers . pop ( ) ;
88+ if ( last ) {
89+ tooltipText = _t ( "%(members)s and %(last)s" , {
90+ members : tooltipMembers . join ( ", " ) ,
91+ last : last ,
92+ } ) ;
93+ } else {
94+ tooltipText = tooltipMembers . join ( ", " ) ;
95+ }
96+ }
97+
7598 const [ { showTooltip, hideTooltip } , tooltip ] = useTooltip ( {
76- label : _t ( "Seen by %(count)s people" , { count : readReceipts . length } ) ,
99+ label : (
100+ < >
101+ < div className = "mx_Tooltip_title" >
102+ { _t ( "Seen by %(count)s people" , { count : readReceipts . length } ) }
103+ </ div >
104+ < div className = "mx_Tooltip_sub" >
105+ { tooltipText }
106+ </ div >
107+ </ >
108+ ) ,
77109 alignment : Alignment . TopRight ,
78110 } ) ;
79111
@@ -97,11 +129,6 @@ export function ReadReceiptGroup(
97129 ) ;
98130 }
99131
100- // If we are above MAX_READ_AVATARS, we’ll have to remove a few to have space for the +n count.
101- const maxAvatars = readReceipts . length > MAX_READ_AVATARS
102- ? MAX_READ_AVATARS_PLUS_N
103- : MAX_READ_AVATARS ;
104-
105132 const avatars = readReceipts . map ( ( receipt , index ) => {
106133 const { hidden, position } = determineAvatarPosition ( index , readReceipts . length , maxAvatars ) ;
107134
0 commit comments