mastodon/app/javascript/mastodon/features/compose/containers/compose_form_container.js

67 lines
1.9 KiB
JavaScript
Raw Normal View History

import { connect } from 'react-redux';
import ComposeForm from '../components/compose_form';
2017-03-01 02:56:15 -08:00
import { uploadCompose } from '../../../actions/compose';
import {
changeCompose,
submitCompose,
clearComposeSuggestions,
fetchComposeSuggestions,
selectComposeSuggestion,
changeComposeSpoilerText,
insertEmojiCompose,
} from '../../../actions/compose';
const mapStateToProps = state => ({
text: state.getIn(['compose', 'text']),
suggestion_token: state.getIn(['compose', 'suggestion_token']),
suggestions: state.getIn(['compose', 'suggestions']),
spoiler: state.getIn(['compose', 'spoiler']),
spoiler_text: state.getIn(['compose', 'spoiler_text']),
privacy: state.getIn(['compose', 'privacy']),
focusDate: state.getIn(['compose', 'focusDate']),
caretPosition: state.getIn(['compose', 'caretPosition']),
preselectDate: state.getIn(['compose', 'preselectDate']),
is_submitting: state.getIn(['compose', 'is_submitting']),
is_uploading: state.getIn(['compose', 'is_uploading']),
showSearch: state.getIn(['search', 'submitted']) && !state.getIn(['search', 'hidden']),
anyMedia: state.getIn(['compose', 'media_attachments']).size > 0,
});
2017-02-22 06:43:07 -08:00
const mapDispatchToProps = (dispatch) => ({
2017-02-22 06:43:07 -08:00
onChange (text) {
dispatch(changeCompose(text));
},
2016-08-31 13:58:10 -07:00
onSubmit (router) {
dispatch(submitCompose(router));
2017-02-22 06:43:07 -08:00
},
2017-02-22 06:43:07 -08:00
onClearSuggestions () {
dispatch(clearComposeSuggestions());
},
2017-02-22 06:43:07 -08:00
onFetchSuggestions (token) {
dispatch(fetchComposeSuggestions(token));
},
2017-02-22 06:43:07 -08:00
onSuggestionSelected (position, token, accountId) {
dispatch(selectComposeSuggestion(position, token, accountId));
},
2017-02-22 06:43:07 -08:00
onChangeSpoilerText (checked) {
dispatch(changeComposeSpoilerText(checked));
},
2017-03-01 02:56:15 -08:00
onPaste (files) {
dispatch(uploadCompose(files));
},
onPickEmoji (position, data, needsSpace) {
dispatch(insertEmojiCompose(position, data, needsSpace));
2017-03-01 15:57:55 -08:00
},
2017-02-22 06:43:07 -08:00
});
2017-02-22 06:43:07 -08:00
export default connect(mapStateToProps, mapDispatchToProps)(ComposeForm);