@@ -65,7 +65,7 @@ export class MessageListComponent
6565 private latestMessage : { id : string ; created_at : Date } | undefined ;
6666 private hasNewMessages : boolean | undefined ;
6767 private containerHeight : number | undefined ;
68- private oldestMessageDate : Date | undefined ;
68+ private oldestMessage : { id : string ; created_at : Date } | undefined ;
6969 private olderMassagesLoaded : boolean | undefined ;
7070 private isNewMessageSentByUser : boolean | undefined ;
7171 private subscriptions : Subscription [ ] = [ ] ;
@@ -345,13 +345,17 @@ export class MessageListComponent
345345 }
346346 const currentLatestMessage = messages [ messages . length - 1 ] ;
347347 this . newMessageReceived ( currentLatestMessage ) ;
348- const currentOldestMessageDate = messages [ 0 ] . created_at ;
349- if ( ! this . oldestMessageDate ) {
350- this . oldestMessageDate = currentOldestMessageDate ;
348+ const currentOldestMessage = messages [ 0 ] ;
349+ if (
350+ ! this . oldestMessage ||
351+ ! messages . find ( ( m ) => m . id === this . oldestMessage ! . id )
352+ ) {
353+ this . oldestMessage = currentOldestMessage ;
351354 } else if (
352- this . oldestMessageDate ?. getTime ( ) > currentOldestMessageDate . getTime ( )
355+ this . oldestMessage . created_at . getTime ( ) >
356+ currentOldestMessage . created_at . getTime ( )
353357 ) {
354- this . oldestMessageDate = currentOldestMessageDate ;
358+ this . oldestMessage = currentOldestMessage ;
355359 this . olderMassagesLoaded = true ;
356360 }
357361 } ) ,
@@ -391,7 +395,7 @@ export class MessageListComponent
391395 this . isUserScrolled = false ;
392396 this . containerHeight = undefined ;
393397 this . olderMassagesLoaded = false ;
394- this . oldestMessageDate = undefined ;
398+ this . oldestMessage = undefined ;
395399 this . unreadMessageCount = 0 ;
396400 this . prevScrollTop = undefined ;
397401 this . isNewMessageSentByUser = undefined ;
0 commit comments