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';
import {
changeCompose,
submitCompose,
clearComposeSuggestions,
fetchComposeSuggestions,
selectComposeSuggestion,
changeComposeSpoilerText,
insertEmojiCompose,
2019-04-22 14:55:24 +02:00
uploadCompose,
} from '../../../actions/compose';
const mapStateToProps = state => ({
text: state.getIn(['compose', 'text']),
suggestions: state.getIn(['compose', 'suggestions']),
spoiler: state.getIn(['compose', 'spoiler']),
2019-04-22 14:55:24 +02:00
spoilerText: 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']),
2019-05-19 18:41:41 +02:00
isSubmitting: state.getIn(['compose', 'is_submitting']),
2019-04-22 14:55:24 +02:00
isChangingUpload: state.getIn(['compose', 'is_changing_upload']),
isUploading: 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
onSubmit (router) {
dispatch(submitCompose(router));
2017-02-22 15:43:07 +01:00
},
2017-02-22 15:43:07 +01:00
onClearSuggestions () {
dispatch(clearComposeSuggestions());
},
2017-02-22 15:43:07 +01:00
onFetchSuggestions (token) {
dispatch(fetchComposeSuggestions(token));
},
2019-04-22 14:55:24 +02:00
onSuggestionSelected (position, token, suggestion) {
dispatch(selectComposeSuggestion(position, token, suggestion));
2017-02-22 15:43:07 +01:00
},
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);