@@ -132,8 +132,8 @@ class MessageInput extends PureComponent {
132132 ...state ,
133133 asyncIds : Immutable ( [ ] ) , // saves data for images that resolve after hitting send
134134 asyncUploads : Immutable ( { } ) , // saves data for images that resolve after hitting send
135- sending : false ,
136135 } ;
136+ this . sending = false ;
137137 }
138138
139139 static themePath = 'messageInput' ;
@@ -343,9 +343,9 @@ class MessageInput extends PureComponent {
343343 * When successful image upload response occurs after hitting send,
344344 * send a follow up message with the image
345345 */
346- this . setState ( { sending : true } ) ;
346+ this . sending = true ;
347347 this . state . asyncIds . forEach ( ( id ) => this . sendMessageAsync ( id ) ) ;
348- this . setState ( { sending : false } ) ;
348+ this . sending = false ;
349349 }
350350
351351 if ( this . props . editing ) this . inputBox . focus ( ) ;
@@ -460,12 +460,11 @@ class MessageInput extends PureComponent {
460460 } ;
461461
462462 sendMessage = async ( ) => {
463- if ( this . state . sending ) return ;
463+ if ( this . sending ) return ;
464+ this . sending = true ;
464465
465466 const { text } = this . state ;
466- await this . setState ( { sending : true , text : '' } , ( ) =>
467- this . inputBox . clear ( ) ,
468- ) ;
467+ await this . setState ( { text : '' } , ( ) => this . inputBox . clear ( ) ) ;
469468
470469 const attachments = [ ] ;
471470 for ( const id of this . state . imageOrder ) {
@@ -486,7 +485,8 @@ class MessageInput extends PureComponent {
486485 asyncIds : [ ...prevState . asyncIds , id ] ,
487486 } ) ) ;
488487 } else {
489- return this . setState ( { sending : false , text } ) ;
488+ this . sending = false ;
489+ return this . setState ( { text } ) ;
490490 }
491491 }
492492
@@ -506,7 +506,7 @@ class MessageInput extends PureComponent {
506506 }
507507 if ( upload . state === FileState . UPLOADING ) {
508508 // TODO: show error to user that they should wait until image is uploaded
509- return this . setState ( { sending : false } ) ;
509+ return ( this . sending = false ) ;
510510 }
511511 if ( upload . state === FileState . UPLOADED ) {
512512 attachments . push ( {
@@ -521,7 +521,7 @@ class MessageInput extends PureComponent {
521521
522522 // Disallow sending message if its empty.
523523 if ( ! text && attachments . length === 0 ) {
524- return this . setState ( { sending : false } ) ;
524+ return ( this . sending = false ) ;
525525 }
526526
527527 if ( this . props . editing ) {
@@ -540,7 +540,7 @@ class MessageInput extends PureComponent {
540540 . then ( this . props . clearEditingState ) ;
541541 logChatPromiseExecution ( updateMessagePromise , 'update message' ) ;
542542
543- this . setState ( { sending : false } ) ;
543+ this . sending = false ;
544544 } else {
545545 try {
546546 this . props . sendMessage ( {
@@ -550,6 +550,7 @@ class MessageInput extends PureComponent {
550550 attachments,
551551 } ) ;
552552
553+ this . sending = false ;
553554 this . setState ( ( prevState ) => ( {
554555 text : '' ,
555556 imageUploads : Immutable ( { } ) ,
@@ -558,10 +559,10 @@ class MessageInput extends PureComponent {
558559 fileOrder : Immutable ( [ ] ) ,
559560 mentioned_users : [ ] ,
560561 numberOfUploads : prevState . numberOfUploads - attachments . length ,
561- sending : false ,
562562 } ) ) ;
563563 } catch ( err ) {
564- this . setState ( { sending : false , text } ) ;
564+ this . sending = false ;
565+ this . setState ( { text } ) ;
565566 console . log ( 'Failed' ) ;
566567 }
567568 }
@@ -818,7 +819,7 @@ class MessageInput extends PureComponent {
818819 } ;
819820
820821 onChangeText = ( text ) => {
821- if ( this . state . sending ) return ;
822+ if ( this . sending ) return ;
822823 this . setState ( { text } ) ;
823824
824825 if ( text ) {
@@ -998,9 +999,7 @@ class MessageInput extends PureComponent {
998999 title = { t ( 'Send message' ) }
9991000 sendMessage = { this . sendMessage }
10001001 editing = { this . props . editing }
1001- disabled = {
1002- disabled || this . state . sending || ! this . isValidMessage ( )
1003- }
1002+ disabled = { disabled || this . sending || ! this . isValidMessage ( ) }
10041003 />
10051004 </ >
10061005 ) }
0 commit comments