1- import { OnInit } from '@angular/core' ;
21import {
32 AfterViewInit ,
43 ChangeDetectorRef ,
@@ -40,7 +39,7 @@ import { TextareaInterface } from './textarea.interface';
4039 providers : [ AttachmentService ] ,
4140} )
4241export class MessageInputComponent
43- implements OnInit , OnChanges , OnDestroy , AfterViewInit
42+ implements OnChanges , OnDestroy , AfterViewInit
4443{
4544 @Input ( ) isFileUploadEnabled : boolean | undefined ;
4645 @Input ( ) areMentionsEnabled : boolean | undefined ;
@@ -64,6 +63,7 @@ export class MessageInputComponent
6463 private textareaAnchor ! : TextareaDirective ;
6564 private subscriptions : Subscription [ ] = [ ] ;
6665 private hideNotification : Function | undefined ;
66+ private isViewInited = false ;
6767
6868 constructor (
6969 private channelService : ChannelService ,
@@ -85,17 +85,6 @@ export class MessageInputComponent
8585 }
8686 )
8787 ) ;
88- this . attachmentUploads$ = this . attachmentService . attachmentUploads$ ;
89- this . isFileUploadEnabled = this . configService . isFileUploadEnabled ;
90- this . acceptedFileTypes = this . configService . acceptedFileTypes ;
91- this . isMultipleFileUploadEnabled =
92- this . configService . isMultipleFileUploadEnabled ;
93- this . areMentionsEnabled = this . configService . areMentionsEnabled ;
94- this . mentionAutocompleteItemTemplate =
95- this . configService . mentionAutocompleteItemTemplate ;
96- this . mentionScope = this . configService . mentionScope ;
97- }
98- ngOnInit ( ) : void {
9988 this . subscriptions . push (
10089 this . channelService . activeChannel$ . subscribe ( ( channel ) => {
10190 this . textareaValue = '' ;
@@ -106,14 +95,26 @@ export class MessageInputComponent
10695 capabilities . indexOf ( 'upload-file' ) !== - 1 ;
10796 this . canSendLinks = capabilities . indexOf ( 'send-links' ) !== - 1 ;
10897 this . canSendMessages = capabilities . indexOf ( 'send-message' ) !== - 1 ;
109- this . cdRef . detectChanges ( ) ;
110- this . initTextarea ( ) ;
98+ if ( this . isViewInited ) {
99+ this . cdRef . detectChanges ( ) ;
100+ this . initTextarea ( ) ;
101+ }
111102 }
112103 } )
113104 ) ;
105+ this . attachmentUploads$ = this . attachmentService . attachmentUploads$ ;
106+ this . isFileUploadEnabled = this . configService . isFileUploadEnabled ;
107+ this . acceptedFileTypes = this . configService . acceptedFileTypes ;
108+ this . isMultipleFileUploadEnabled =
109+ this . configService . isMultipleFileUploadEnabled ;
110+ this . areMentionsEnabled = this . configService . areMentionsEnabled ;
111+ this . mentionAutocompleteItemTemplate =
112+ this . configService . mentionAutocompleteItemTemplate ;
113+ this . mentionScope = this . configService . mentionScope ;
114114 }
115115
116116 ngAfterViewInit ( ) : void {
117+ this . isViewInited = true ;
117118 this . initTextarea ( ) ;
118119 }
119120
0 commit comments