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 11:56:15 +01: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 15:43:07 +01:00
const mapDispatchToProps = (dispatch) => ({
2017-02-22 15:43:07 +01:00
onChange (text) {
dispatch(changeCompose(text));
},
2016-08-31 22:58:10 +02:00
2017-02-22 15:43:07 +01:00
onSubmit () {
dispatch(submitCompose());
},
2017-02-22 15:43:07 +01:00
onClearSuggestions () {
dispatch(clearComposeSuggestions());
},
2017-02-22 15:43:07 +01:00
onFetchSuggestions (token) {
dispatch(fetchComposeSuggestions(token));
},
2017-02-22 15:43:07 +01:00
onSuggestionSelected (position, token, accountId) {
dispatch(selectComposeSuggestion(position, token, accountId));
},
2017-02-22 15:43:07 +01:00
onChangeSpoilerText (checked) {
dispatch(changeComposeSpoilerText(checked));
},
2017-03-01 11:56:15 +01:00
onPaste (files) {
dispatch(uploadCompose(files));
},
onPickEmoji (position, data, needsSpace) {
dispatch(insertEmojiCompose(position, data, needsSpace));
2017-03-02 00:57:55 +01:00
},
2017-02-22 15:43:07 +01:00
});
2017-02-22 15:43:07 +01:00
export default connect(mapStateToProps, mapDispatchToProps)(ComposeForm);