2019-04-21 09:31:26 -07:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import Options from '../components/options';
|
|
|
|
import {
|
|
|
|
changeComposeAdvancedOption,
|
2019-05-20 01:05:11 -07:00
|
|
|
changeComposeContentType,
|
|
|
|
addPoll,
|
|
|
|
removePoll,
|
2019-04-21 09:31:26 -07:00
|
|
|
} from 'flavours/glitch/actions/compose';
|
|
|
|
import { closeModal, openModal } from 'flavours/glitch/actions/modal';
|
|
|
|
|
|
|
|
function mapStateToProps (state) {
|
|
|
|
const spoilersAlwaysOn = state.getIn(['local_settings', 'always_show_spoilers_field']);
|
|
|
|
const poll = state.getIn(['compose', 'poll']);
|
|
|
|
const media = state.getIn(['compose', 'media_attachments']);
|
|
|
|
return {
|
|
|
|
acceptContentTypes: state.getIn(['media_attachments', 'accept_content_types']).toArray().join(','),
|
|
|
|
resetFileKey: state.getIn(['compose', 'resetFileKey']),
|
|
|
|
hasPoll: !!poll,
|
|
|
|
allowMedia: !poll && (media ? media.size < 4 && !media.some(item => item.get('type') === 'video') : true),
|
|
|
|
hasMedia: media && !!media.size,
|
|
|
|
allowPoll: !(media && !!media.size),
|
2019-05-12 12:55:44 -07:00
|
|
|
showContentTypeChoice: state.getIn(['local_settings', 'show_content_type_choice']),
|
2019-05-20 01:05:11 -07:00
|
|
|
contentType: state.getIn(['compose', 'content_type']),
|
2019-04-21 09:31:26 -07:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
|
|
|
|
|
|
|
onChangeAdvancedOption(option, value) {
|
|
|
|
dispatch(changeComposeAdvancedOption(option, value));
|
|
|
|
},
|
|
|
|
|
2019-05-20 01:05:11 -07:00
|
|
|
onChangeContentType(value) {
|
|
|
|
dispatch(changeComposeContentType(value));
|
|
|
|
},
|
|
|
|
|
2019-04-21 09:31:26 -07:00
|
|
|
onTogglePoll() {
|
|
|
|
dispatch((_, getState) => {
|
|
|
|
if (getState().getIn(['compose', 'poll'])) {
|
|
|
|
dispatch(removePoll());
|
|
|
|
} else {
|
|
|
|
dispatch(addPoll());
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
onDoodleOpen() {
|
|
|
|
dispatch(openModal('DOODLE', { noEsc: true }));
|
|
|
|
},
|
|
|
|
|
|
|
|
onModalClose() {
|
|
|
|
dispatch(closeModal());
|
|
|
|
},
|
|
|
|
|
|
|
|
onModalOpen(props) {
|
|
|
|
dispatch(openModal('ACTIONS', props));
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(Options);
|