]> cat aescling's git repositories - mastodon.git/blob - app/javascript/mastodon/features/compose/containers/compose_form_container.js
Refactor initial state: "me" (#5563)
[mastodon.git] / app / javascript / mastodon / features / compose / containers / compose_form_container.js
1 import { connect } from 'react-redux';
2 import ComposeForm from '../components/compose_form';
3 import { uploadCompose } from '../../../actions/compose';
4 import {
5 changeCompose,
6 submitCompose,
7 clearComposeSuggestions,
8 fetchComposeSuggestions,
9 selectComposeSuggestion,
10 changeComposeSpoilerText,
11 insertEmojiCompose,
12 } from '../../../actions/compose';
13
14 const mapStateToProps = state => ({
15 text: state.getIn(['compose', 'text']),
16 suggestion_token: state.getIn(['compose', 'suggestion_token']),
17 suggestions: state.getIn(['compose', 'suggestions']),
18 spoiler: state.getIn(['compose', 'spoiler']),
19 spoiler_text: state.getIn(['compose', 'spoiler_text']),
20 privacy: state.getIn(['compose', 'privacy']),
21 focusDate: state.getIn(['compose', 'focusDate']),
22 preselectDate: state.getIn(['compose', 'preselectDate']),
23 is_submitting: state.getIn(['compose', 'is_submitting']),
24 is_uploading: state.getIn(['compose', 'is_uploading']),
25 showSearch: state.getIn(['search', 'submitted']) && !state.getIn(['search', 'hidden']),
26 });
27
28 const mapDispatchToProps = (dispatch) => ({
29
30 onChange (text) {
31 dispatch(changeCompose(text));
32 },
33
34 onSubmit () {
35 dispatch(submitCompose());
36 },
37
38 onClearSuggestions () {
39 dispatch(clearComposeSuggestions());
40 },
41
42 onFetchSuggestions (token) {
43 dispatch(fetchComposeSuggestions(token));
44 },
45
46 onSuggestionSelected (position, token, accountId) {
47 dispatch(selectComposeSuggestion(position, token, accountId));
48 },
49
50 onChangeSpoilerText (checked) {
51 dispatch(changeComposeSpoilerText(checked));
52 },
53
54 onPaste (files) {
55 dispatch(uploadCompose(files));
56 },
57
58 onPickEmoji (position, data) {
59 dispatch(insertEmojiCompose(position, data));
60 },
61
62 });
63
64 export default connect(mapStateToProps, mapDispatchToProps)(ComposeForm);
This page took 0.079855 seconds and 4 git commands to generate.