Refactor contentType selection in glitch composer

th-downstream
Thibaut Girka 6 years ago committed by ThibG
parent 0bc9d4f6d3
commit a0b7246388

@ -38,7 +38,6 @@ class ComposeForm extends ImmutablePureComponent {
suggestions: ImmutablePropTypes.list, suggestions: ImmutablePropTypes.list,
spoiler: PropTypes.bool, spoiler: PropTypes.bool,
privacy: PropTypes.string, privacy: PropTypes.string,
contentType: PropTypes.string,
spoilerText: PropTypes.string, spoilerText: PropTypes.string,
focusDate: PropTypes.instanceOf(Date), focusDate: PropTypes.instanceOf(Date),
caretPosition: PropTypes.number, caretPosition: PropTypes.number,
@ -67,7 +66,6 @@ class ComposeForm extends ImmutablePureComponent {
preselectOnReply: PropTypes.bool, preselectOnReply: PropTypes.bool,
onChangeSpoilerness: PropTypes.func, onChangeSpoilerness: PropTypes.func,
onChangeVisibility: PropTypes.func, onChangeVisibility: PropTypes.func,
onChangeContentType: PropTypes.func,
onMount: PropTypes.func, onMount: PropTypes.func,
onUnmount: PropTypes.func, onUnmount: PropTypes.func,
onPaste: PropTypes.func, onPaste: PropTypes.func,
@ -287,12 +285,10 @@ class ComposeForm extends ImmutablePureComponent {
media, media,
onChangeSpoilerness, onChangeSpoilerness,
onChangeVisibility, onChangeVisibility,
onChangeContentType,
onClearSuggestions, onClearSuggestions,
onFetchSuggestions, onFetchSuggestions,
onPaste, onPaste,
privacy, privacy,
contentType,
sensitive, sensitive,
showSearch, showSearch,
sideArm, sideArm,
@ -360,11 +356,9 @@ class ComposeForm extends ImmutablePureComponent {
advancedOptions={advancedOptions} advancedOptions={advancedOptions}
disabled={isSubmitting} disabled={isSubmitting}
onChangeVisibility={onChangeVisibility} onChangeVisibility={onChangeVisibility}
onChangeContentType={onChangeContentType}
onToggleSpoiler={spoilersAlwaysOn ? null : onChangeSpoilerness} onToggleSpoiler={spoilersAlwaysOn ? null : onChangeSpoilerness}
onUpload={onPaste} onUpload={onPaste}
privacy={privacy} privacy={privacy}
contentType={contentType}
sensitive={sensitive || (spoilersAlwaysOn && spoilerText && spoilerText.length > 0)} sensitive={sensitive || (spoilersAlwaysOn && spoilerText && spoilerText.length > 0)}
spoiler={spoilersAlwaysOn ? (spoilerText && spoilerText.length > 0) : spoiler} spoiler={spoilersAlwaysOn ? (spoilerText && spoilerText.length > 0) : spoiler}
/> />
@ -375,7 +369,6 @@ class ComposeForm extends ImmutablePureComponent {
onSecondarySubmit={handleSecondarySubmit} onSecondarySubmit={handleSecondarySubmit}
onSubmit={handleSubmit} onSubmit={handleSubmit}
privacy={privacy} privacy={privacy}
contentType={contentType}
sideArm={sideArm} sideArm={sideArm}
/> />
</div> </div>

@ -6,7 +6,6 @@ import {
changeComposeSpoilerText, changeComposeSpoilerText,
changeComposeSpoilerness, changeComposeSpoilerness,
changeComposeVisibility, changeComposeVisibility,
changeComposeContentType,
clearComposeSuggestions, clearComposeSuggestions,
fetchComposeSuggestions, fetchComposeSuggestions,
insertEmojiCompose, insertEmojiCompose,
@ -58,7 +57,6 @@ function mapStateToProps (state) {
media: state.getIn(['compose', 'media_attachments']), media: state.getIn(['compose', 'media_attachments']),
preselectDate: state.getIn(['compose', 'preselectDate']), preselectDate: state.getIn(['compose', 'preselectDate']),
privacy: state.getIn(['compose', 'privacy']), privacy: state.getIn(['compose', 'privacy']),
contentType: state.getIn(['compose', 'content_type']),
sideArm: sideArmPrivacy, sideArm: sideArmPrivacy,
sensitive: state.getIn(['compose', 'sensitive']), sensitive: state.getIn(['compose', 'sensitive']),
showSearch: state.getIn(['search', 'submitted']) && !state.getIn(['search', 'hidden']), showSearch: state.getIn(['search', 'submitted']) && !state.getIn(['search', 'hidden']),
@ -100,10 +98,6 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
dispatch(changeComposeSpoilerText(text)); dispatch(changeComposeSpoilerText(text));
}, },
onChangeContentType(value) {
dispatch(changeComposeContentType(value));
},
onPaste(files) { onPaste(files) {
dispatch(uploadCompose(files)); dispatch(uploadCompose(files));
}, },

@ -2,8 +2,10 @@ import { connect } from 'react-redux';
import Options from '../components/options'; import Options from '../components/options';
import { import {
changeComposeAdvancedOption, changeComposeAdvancedOption,
changeComposeContentType,
addPoll,
removePoll,
} from 'flavours/glitch/actions/compose'; } from 'flavours/glitch/actions/compose';
import { addPoll, removePoll } from 'flavours/glitch/actions/compose';
import { closeModal, openModal } from 'flavours/glitch/actions/modal'; import { closeModal, openModal } from 'flavours/glitch/actions/modal';
function mapStateToProps (state) { function mapStateToProps (state) {
@ -18,6 +20,7 @@ function mapStateToProps (state) {
hasMedia: media && !!media.size, hasMedia: media && !!media.size,
allowPoll: !(media && !!media.size), allowPoll: !(media && !!media.size),
showContentTypeChoice: state.getIn(['local_settings', 'show_content_type_choice']), showContentTypeChoice: state.getIn(['local_settings', 'show_content_type_choice']),
contentType: state.getIn(['compose', 'content_type']),
}; };
}; };
@ -27,6 +30,10 @@ const mapDispatchToProps = (dispatch) => ({
dispatch(changeComposeAdvancedOption(option, value)); dispatch(changeComposeAdvancedOption(option, value));
}, },
onChangeContentType(value) {
dispatch(changeComposeContentType(value));
},
onTogglePoll() { onTogglePoll() {
dispatch((_, getState) => { dispatch((_, getState) => {
if (getState().getIn(['compose', 'poll'])) { if (getState().getIn(['compose', 'poll'])) {

Loading…
Cancel
Save