diff --git a/app/javascript/mastodon/features/ui/index.jsx b/app/javascript/mastodon/features/ui/index.jsx index 79f7f8c3b24..a420279ca40 100644 --- a/app/javascript/mastodon/features/ui/index.jsx +++ b/app/javascript/mastodon/features/ui/index.jsx @@ -92,8 +92,7 @@ const messages = defineMessages({ const mapStateToProps = state => ({ layout: state.getIn(['meta', 'layout']), isComposing: state.getIn(['compose', 'is_composing']), - hasComposingText: state.getIn(['compose', 'text']).trim().length !== 0, - hasMediaAttachments: state.getIn(['compose', 'media_attachments']).size > 0, + hasComposingContents: state.getIn(['compose', 'text']).trim().length !== 0 || state.getIn(['compose', 'media_attachments']).size > 0 || state.getIn(['compose', 'poll']) !== null, canUploadMore: !state.getIn(['compose', 'media_attachments']).some(x => ['audio', 'video'].includes(x.get('type'))) && state.getIn(['compose', 'media_attachments']).size < state.getIn(['server', 'server', 'configuration', 'statuses', 'max_media_attachments']), firstLaunch: state.getIn(['settings', 'introductionVersion'], 0) < INTRODUCTION_VERSION, newAccount: !state.getIn(['accounts', me, 'note']) && !state.getIn(['accounts', me, 'bot']) && state.getIn(['accounts', me, 'following_count'], 0) === 0 && state.getIn(['accounts', me, 'statuses_count'], 0) === 0, @@ -241,8 +240,7 @@ class UI extends PureComponent { dispatch: PropTypes.func.isRequired, children: PropTypes.node, isComposing: PropTypes.bool, - hasComposingText: PropTypes.bool, - hasMediaAttachments: PropTypes.bool, + hasComposingContents: PropTypes.bool, canUploadMore: PropTypes.bool, intl: PropTypes.object.isRequired, layout: PropTypes.string.isRequired, @@ -257,11 +255,11 @@ class UI extends PureComponent { }; handleBeforeUnload = e => { - const { intl, dispatch, isComposing, hasComposingText, hasMediaAttachments } = this.props; + const { intl, dispatch, isComposing, hasComposingContents } = this.props; dispatch(synchronouslySubmitMarkers()); - if (isComposing && (hasComposingText || hasMediaAttachments)) { + if (isComposing && hasComposingContents) { e.preventDefault(); // Setting returnValue to any string causes confirmation dialog. // Many browsers no longer display this text to users,