@@ -297,30 +297,6 @@ export class MessageListComponent
297297 }
298298 )
299299 ) ;
300- this . setMessages$ ( ) ;
301- }
302-
303- ngOnChanges ( changes : SimpleChanges ) : void {
304- if ( changes . mode || changes . direction ) {
305- this . setMessages$ ( ) ;
306- }
307- if ( changes . direction ) {
308- if ( this . scrollContainer ?. nativeElement ) {
309- this . jumpToLatestMessage ( ) ;
310- }
311- }
312- if ( changes . customMessageActions ) {
313- this . messageActionsService . customActions$ . next ( this . customMessageActions ) ;
314- }
315- }
316-
317- ngAfterViewInit ( ) : void {
318- this . isViewInited = true ;
319- this . ngZone . runOutsideAngular ( ( ) => {
320- this . scrollContainer . nativeElement . addEventListener ( 'scroll' , ( ) =>
321- this . scrolled ( )
322- ) ;
323- } ) ;
324300 this . subscriptions . push (
325301 this . channelService . jumpToMessage$
326302 . pipe ( filter ( ( config ) => ! ! config . id ) )
@@ -339,7 +315,9 @@ export class MessageListComponent
339315 if ( messageId ) {
340316 if ( messageId === 'latest' ) {
341317 this . scrollToLatestMessage ( ) ;
342- this . cdRef . detectChanges ( ) ;
318+ if ( this . isViewInited ) {
319+ this . cdRef . detectChanges ( ) ;
320+ }
343321 } else {
344322 this . scrollMessageIntoView ( messageId ) ;
345323 this . highlightedMessageId = messageId ;
@@ -352,7 +330,7 @@ export class MessageListComponent
352330 ( template ) => {
353331 const isChanged = this . emptyMainMessageListTemplate !== template ;
354332 this . emptyMainMessageListTemplate = template || null ;
355- if ( isChanged ) {
333+ if ( isChanged && this . isViewInited ) {
356334 this . cdRef . detectChanges ( ) ;
357335 }
358336 }
@@ -363,12 +341,36 @@ export class MessageListComponent
363341 ( template ) => {
364342 const isChanged = this . emptyThreadMessageListTemplate !== template ;
365343 this . emptyThreadMessageListTemplate = template || null ;
366- if ( isChanged ) {
344+ if ( isChanged && this . isViewInited ) {
367345 this . cdRef . detectChanges ( ) ;
368346 }
369347 }
370348 )
371349 ) ;
350+ this . setMessages$ ( ) ;
351+ }
352+
353+ ngOnChanges ( changes : SimpleChanges ) : void {
354+ if ( changes . mode || changes . direction ) {
355+ this . setMessages$ ( ) ;
356+ }
357+ if ( changes . direction ) {
358+ if ( this . scrollContainer ?. nativeElement ) {
359+ this . jumpToLatestMessage ( ) ;
360+ }
361+ }
362+ if ( changes . customMessageActions ) {
363+ this . messageActionsService . customActions$ . next ( this . customMessageActions ) ;
364+ }
365+ }
366+
367+ ngAfterViewInit ( ) : void {
368+ this . isViewInited = true ;
369+ this . ngZone . runOutsideAngular ( ( ) => {
370+ this . scrollContainer . nativeElement . addEventListener ( 'scroll' , ( ) =>
371+ this . scrolled ( )
372+ ) ;
373+ } ) ;
372374 }
373375
374376 ngAfterViewChecked ( ) {
0 commit comments