2016-10-30 13:13:05 -04:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import ComposeForm from '../components/compose_form';
|
|
|
|
import {
|
|
|
|
changeCompose,
|
|
|
|
submitCompose,
|
|
|
|
clearComposeSuggestions,
|
2016-11-12 08:33:21 -05:00
|
|
|
fetchComposeSuggestions,
|
2016-11-23 12:53:23 -05:00
|
|
|
selectComposeSuggestion,
|
2017-01-12 23:54:26 -05:00
|
|
|
changeComposeSpoilerText,
|
2017-05-20 11:31:47 -04:00
|
|
|
insertEmojiCompose,
|
2019-04-22 08:55:24 -04:00
|
|
|
uploadCompose,
|
2016-10-30 13:13:05 -04:00
|
|
|
} from '../../../actions/compose';
|
2016-09-05 10:56:43 -04:00
|
|
|
|
2017-04-23 18:38:37 -04:00
|
|
|
const mapStateToProps = state => ({
|
|
|
|
text: state.getIn(['compose', 'text']),
|
|
|
|
suggestions: state.getIn(['compose', 'suggestions']),
|
|
|
|
spoiler: state.getIn(['compose', 'spoiler']),
|
2019-04-22 08:55:24 -04:00
|
|
|
spoilerText: state.getIn(['compose', 'spoiler_text']),
|
2017-04-23 18:38:37 -04:00
|
|
|
privacy: state.getIn(['compose', 'privacy']),
|
|
|
|
focusDate: state.getIn(['compose', 'focusDate']),
|
2018-05-23 09:20:15 -04:00
|
|
|
caretPosition: state.getIn(['compose', 'caretPosition']),
|
2017-04-23 18:38:37 -04:00
|
|
|
preselectDate: state.getIn(['compose', 'preselectDate']),
|
2019-05-19 12:41:41 -04:00
|
|
|
isSubmitting: state.getIn(['compose', 'is_submitting']),
|
2022-02-09 18:15:30 -05:00
|
|
|
isEditing: state.getIn(['compose', 'id']) !== null,
|
2019-04-22 08:55:24 -04:00
|
|
|
isChangingUpload: state.getIn(['compose', 'is_changing_upload']),
|
|
|
|
isUploading: state.getIn(['compose', 'is_uploading']),
|
2017-05-20 11:31:47 -04:00
|
|
|
showSearch: state.getIn(['search', 'submitted']) && !state.getIn(['search', 'hidden']),
|
2018-03-07 02:28:52 -05:00
|
|
|
anyMedia: state.getIn(['compose', 'media_attachments']).size > 0,
|
2022-01-20 14:56:21 -05:00
|
|
|
isInReply: state.getIn(['compose', 'in_reply_to']) !== null,
|
2017-02-25 19:23:44 -05:00
|
|
|
});
|
|
|
|
|
2017-02-22 09:43:07 -05:00
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
2016-08-31 10:15:12 -04:00
|
|
|
|
2017-02-22 09:43:07 -05:00
|
|
|
onChange (text) {
|
|
|
|
dispatch(changeCompose(text));
|
|
|
|
},
|
2016-08-31 16:58:10 -04:00
|
|
|
|
2018-10-10 19:31:03 -04:00
|
|
|
onSubmit (router) {
|
|
|
|
dispatch(submitCompose(router));
|
2017-02-22 09:43:07 -05:00
|
|
|
},
|
2016-10-30 13:13:05 -04:00
|
|
|
|
2017-02-22 09:43:07 -05:00
|
|
|
onClearSuggestions () {
|
|
|
|
dispatch(clearComposeSuggestions());
|
|
|
|
},
|
2016-10-30 13:13:05 -04:00
|
|
|
|
2017-02-22 09:43:07 -05:00
|
|
|
onFetchSuggestions (token) {
|
|
|
|
dispatch(fetchComposeSuggestions(token));
|
|
|
|
},
|
2016-11-12 08:33:21 -05:00
|
|
|
|
2019-05-09 16:10:27 -04:00
|
|
|
onSuggestionSelected (position, token, suggestion, path) {
|
|
|
|
dispatch(selectComposeSuggestion(position, token, suggestion, path));
|
2017-02-22 09:43:07 -05:00
|
|
|
},
|
2016-11-23 12:53:23 -05:00
|
|
|
|
2017-02-22 09:43:07 -05:00
|
|
|
onChangeSpoilerText (checked) {
|
|
|
|
dispatch(changeComposeSpoilerText(checked));
|
|
|
|
},
|
2017-01-12 23:54:26 -05:00
|
|
|
|
2017-03-01 05:56:15 -05:00
|
|
|
onPaste (files) {
|
|
|
|
dispatch(uploadCompose(files));
|
|
|
|
},
|
|
|
|
|
2018-04-17 07:50:33 -04:00
|
|
|
onPickEmoji (position, data, needsSpace) {
|
|
|
|
dispatch(insertEmojiCompose(position, data, needsSpace));
|
2017-03-01 18:57:55 -05:00
|
|
|
},
|
|
|
|
|
2017-02-22 09:43:07 -05:00
|
|
|
});
|
2016-08-25 13:52:55 -04:00
|
|
|
|
2017-02-22 09:43:07 -05:00
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(ComposeForm);
|