@@ -125,7 +125,17 @@ export class MessageListComponent
125125 ) {
126126 this . subscriptions . push (
127127 this . channelService . activeChannel$ . subscribe ( ( channel ) => {
128+ this . chatClientService . chatClient ?. logger ?.(
129+ 'info' ,
130+ `${ channel ?. cid || 'undefined' } selected` ,
131+ { tags : `message list ${ this . mode } ` }
132+ ) ;
128133 if ( this . channelId !== channel ?. id ) {
134+ this . chatClientService ?. chatClient ?. logger ?.(
135+ 'info' ,
136+ `new channel is different from prev channel, reseting scroll state` ,
137+ { tags : `message list ${ this . mode } ` }
138+ ) ;
129139 this . resetScrollState ( ) ;
130140 this . channelId = channel ?. id ;
131141 if (
@@ -231,6 +241,11 @@ export class MessageListComponent
231241 } else if ( config . parentId ) {
232242 messageId = config . id ;
233243 }
244+ this . chatClientService . chatClient ?. logger ?.(
245+ 'info' ,
246+ `Jumping to ${ messageId || '' } ` ,
247+ { tags : `message list ${ this . mode } ` }
248+ ) ;
234249 if ( messageId ) {
235250 if ( messageId === 'latest' ) {
236251 this . scrollToLatestMessage ( ) ;
@@ -263,13 +278,25 @@ export class MessageListComponent
263278 } else {
264279 if ( this . hasNewMessages ) {
265280 if ( ! this . isUserScrolled || this . isNewMessageSentByUser ) {
281+ this . chatClientService . chatClient ?. logger ?.(
282+ 'info' ,
283+ `User has new messages, and not scrolled or sent new messages, therefore we ${
284+ this . isLatestMessageInList ? 'scroll' : 'jump'
285+ } to latest message`,
286+ { tags : `message list ${ this . mode } ` }
287+ ) ;
266288 this . isLatestMessageInList
267289 ? this . scrollToBottom ( )
268290 : this . jumpToLatestMessage ( ) ;
269291 }
270292 this . hasNewMessages = false ;
271293 this . containerHeight = this . scrollContainer . nativeElement . scrollHeight ;
272294 } else if ( this . olderMassagesLoaded ) {
295+ this . chatClientService . chatClient ?. logger ?.(
296+ 'info' ,
297+ `Older messages are loaded, we preserve the scroll position` ,
298+ { tags : `message list ${ this . mode } ` }
299+ ) ;
273300 this . preserveScrollbarPosition ( ) ;
274301 this . containerHeight = this . scrollContainer . nativeElement . scrollHeight ;
275302 this . olderMassagesLoaded = false ;
@@ -278,6 +305,13 @@ export class MessageListComponent
278305 ! this . isUserScrolled &&
279306 ! this . highlightedMessageId
280307 ) {
308+ this . chatClientService . chatClient ?. logger ?.(
309+ 'info' ,
310+ `Container grew and user didn't scroll therefore we ${
311+ this . isLatestMessageInList ? 'scroll' : 'jump'
312+ } to latest message`,
313+ { tags : `message list ${ this . mode } ` }
314+ ) ;
281315 this . isLatestMessageInList
282316 ? this . scrollToBottom ( )
283317 : this . jumpToLatestMessage ( ) ;
@@ -333,6 +367,11 @@ export class MessageListComponent
333367 return ;
334368 }
335369 const scrollPosition = this . getScrollPosition ( ) ;
370+ this . chatClientService . chatClient ?. logger ?.(
371+ 'info' ,
372+ `Scrolled - scroll position: ${ scrollPosition } ` ,
373+ { tags : `message list ${ this . mode } ` }
374+ ) ;
336375
337376 this . isUserScrolled =
338377 ( this . direction === 'bottom-to-top'
@@ -440,9 +479,23 @@ export class MessageListComponent
440479 tap ( ( messages ) => {
441480 this . isLoading = false ;
442481 if ( messages . length === 0 ) {
482+ this . chatClientService . chatClient ?. logger ?.(
483+ 'info' ,
484+ `Empty messages array, reseting scroll state` ,
485+ {
486+ tags : `message list ${ this . mode } ` ,
487+ }
488+ ) ;
443489 this . resetScrollState ( ) ;
444490 return ;
445491 }
492+ this . chatClientService . chatClient ?. logger ?.(
493+ 'info' ,
494+ `Received one or more messages` ,
495+ {
496+ tags : `message list ${ this . mode } ` ,
497+ }
498+ ) ;
446499 const currentLatestMessage = messages [ messages . length - 1 ] ;
447500 this . newMessageReceived ( currentLatestMessage ) ;
448501 const currentOldestMessage = messages [ 0 ] ;
@@ -551,6 +604,11 @@ export class MessageListComponent
551604 ! this . latestMessage ||
552605 this . latestMessage . created_at ?. getTime ( ) < message . created_at . getTime ( )
553606 ) {
607+ this . chatClientService . chatClient ?. logger ?.(
608+ 'info' ,
609+ `Received new message` ,
610+ { tags : `message list ${ this . mode } ` }
611+ ) ;
554612 this . latestMessage = message ;
555613 this . hasNewMessages = true ;
556614 this . isNewMessageSentByUser =
0 commit comments