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

68 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 12:55:24 +00: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 12:55:24 +00: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 16:41:41 +00:00
isSubmitting: state.getIn(['compose', 'is_submitting']),
isEditing: state.getIn(['compose', 'id']) !== null,
2019-04-22 12:55:24 +00:00
isChangingUpload: state.getIn(['compose', 'is_changing_upload']),
isUploading: state.getIn(['compose', 'is_uploading']),
anyMedia: state.getIn(['compose', 'media_attachments']).size > 0,
isInReply: state.getIn(['compose', 'in_reply_to']) !== null,
});
2017-02-22 14:43:07 +00:00
const mapDispatchToProps = (dispatch) => ({
2017-02-22 14:43:07 +00:00
onChange (text) {
dispatch(changeCompose(text));
},
2016-08-31 20:58:10 +00:00
onSubmit (router) {
dispatch(submitCompose(router));
2017-02-22 14:43:07 +00:00
},
2017-02-22 14:43:07 +00:00
onClearSuggestions () {
dispatch(clearComposeSuggestions());
},
2017-02-22 14:43:07 +00:00
onFetchSuggestions (token) {
dispatch(fetchComposeSuggestions(token));
},
onSuggestionSelected (position, token, suggestion, path) {
dispatch(selectComposeSuggestion(position, token, suggestion, path));
2017-02-22 14:43:07 +00:00
},
2017-02-22 14:43:07 +00:00
onChangeSpoilerText (checked) {
dispatch(changeComposeSpoilerText(checked));
},
2017-03-01 10:56:15 +00:00
onPaste (files) {
dispatch(uploadCompose(files));
},
onPickEmoji (position, data, needsSpace) {
dispatch(insertEmojiCompose(position, data, needsSpace));
2017-03-01 23:57:55 +00:00
},
2017-02-22 14:43:07 +00:00
});
2017-02-22 14:43:07 +00:00
export default connect(mapStateToProps, mapDispatchToProps)(ComposeForm);