@@ -66,6 +66,7 @@ const mapStateToProps = state => ({
6666 isComposing : state . getIn ( [ 'compose' , 'is_composing' ] ) ,
6767 hasComposingText : state . getIn ( [ 'compose' , 'text' ] ) . trim ( ) . length !== 0 ,
6868 hasMediaAttachments : state . getIn ( [ 'compose' , 'media_attachments' ] ) . size > 0 ,
69+ canUploadMore : ! state . getIn ( [ 'compose' , 'media_attachments' ] ) . some ( x => [ 'audio' , 'video' ] . includes ( x . get ( 'type' ) ) ) && state . getIn ( [ 'compose' , 'media_attachments' ] ) . size < 4 ,
6970 dropdownMenuIsOpen : state . getIn ( [ 'dropdown_menu' , 'openId' ] ) !== null ,
7071} ) ;
7172
@@ -232,6 +233,7 @@ class UI extends React.PureComponent {
232233 isComposing : PropTypes . bool ,
233234 hasComposingText : PropTypes . bool ,
234235 hasMediaAttachments : PropTypes . bool ,
236+ canUploadMore : PropTypes . bool ,
235237 location : PropTypes . object ,
236238 intl : PropTypes . object . isRequired ,
237239 dropdownMenuIsOpen : PropTypes . bool ,
@@ -278,13 +280,14 @@ class UI extends React.PureComponent {
278280 this . dragTargets . push ( e . target ) ;
279281 }
280282
281- if ( e . dataTransfer && Array . from ( e . dataTransfer . types ) . includes ( 'Files' ) ) {
283+ if ( e . dataTransfer && Array . from ( e . dataTransfer . types ) . includes ( 'Files' ) && this . props . canUploadMore ) {
282284 this . setState ( { draggingOver : true } ) ;
283285 }
284286 }
285287
286288 handleDragOver = ( e ) => {
287289 if ( this . dataTransferIsText ( e . dataTransfer ) ) return false ;
290+
288291 e . preventDefault ( ) ;
289292 e . stopPropagation ( ) ;
290293
@@ -299,12 +302,13 @@ class UI extends React.PureComponent {
299302
300303 handleDrop = ( e ) => {
301304 if ( this . dataTransferIsText ( e . dataTransfer ) ) return ;
305+
302306 e . preventDefault ( ) ;
303307
304308 this . setState ( { draggingOver : false } ) ;
305309 this . dragTargets = [ ] ;
306310
307- if ( e . dataTransfer && e . dataTransfer . files . length >= 1 ) {
311+ if ( e . dataTransfer && e . dataTransfer . files . length >= 1 && this . props . canUploadMore ) {
308312 this . props . dispatch ( uploadCompose ( e . dataTransfer . files ) ) ;
309313 }
310314 }
0 commit comments