Refactor contentType selection in glitch composer

This commit is contained in:
Thibaut Girka
2019-05-20 10:05:11 +02:00
committed by ThibG
parent 2cd7bfac23
commit 4fbce23992
3 changed files with 8 additions and 14 deletions

View File

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

View File

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