about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2019-05-20 10:05:11 +0200
committerThibG <thib@sitedethib.com>2019-05-20 10:27:31 +0200
commit4fbce23992c48314f581e07804360a5e14f915b8 (patch)
tree6cdac6d958a4e36aa994e04a863dde2f6dcb5d02 /app/javascript/flavours/glitch
parent2cd7bfac239561ab7ad119d558a6508e66e4ad22 (diff)
Refactor contentType selection in glitch composer
Diffstat (limited to 'app/javascript/flavours/glitch')
-rw-r--r--app/javascript/flavours/glitch/features/compose/components/compose_form.js7
-rw-r--r--app/javascript/flavours/glitch/features/compose/containers/compose_form_container.js6
-rw-r--r--app/javascript/flavours/glitch/features/compose/containers/options_container.js9
3 files changed, 8 insertions, 14 deletions
diff --git a/app/javascript/flavours/glitch/features/compose/components/compose_form.js b/app/javascript/flavours/glitch/features/compose/components/compose_form.js
index 4e93e2d84..e8f000b1e 100644
--- a/app/javascript/flavours/glitch/features/compose/components/compose_form.js
+++ b/app/javascript/flavours/glitch/features/compose/components/compose_form.js
@@ -38,7 +38,6 @@ class ComposeForm extends ImmutablePureComponent {
     suggestions: ImmutablePropTypes.list,
     spoiler: PropTypes.bool,
     privacy: PropTypes.string,
-    contentType: PropTypes.string,
     spoilerText: PropTypes.string,
     focusDate: PropTypes.instanceOf(Date),
     caretPosition: PropTypes.number,
@@ -67,7 +66,6 @@ class ComposeForm extends ImmutablePureComponent {
     preselectOnReply: PropTypes.bool,
     onChangeSpoilerness: PropTypes.func,
     onChangeVisibility: PropTypes.func,
-    onChangeContentType: PropTypes.func,
     onMount: PropTypes.func,
     onUnmount: PropTypes.func,
     onPaste: PropTypes.func,
@@ -287,12 +285,10 @@ class ComposeForm extends ImmutablePureComponent {
       media,
       onChangeSpoilerness,
       onChangeVisibility,
-      onChangeContentType,
       onClearSuggestions,
       onFetchSuggestions,
       onPaste,
       privacy,
-      contentType,
       sensitive,
       showSearch,
       sideArm,
@@ -360,11 +356,9 @@ class ComposeForm extends ImmutablePureComponent {
           advancedOptions={advancedOptions}
           disabled={isSubmitting}
           onChangeVisibility={onChangeVisibility}
-          onChangeContentType={onChangeContentType}
           onToggleSpoiler={spoilersAlwaysOn ? null : onChangeSpoilerness}
           onUpload={onPaste}
           privacy={privacy}
-          contentType={contentType}
           sensitive={sensitive || (spoilersAlwaysOn && spoilerText && spoilerText.length > 0)}
           spoiler={spoilersAlwaysOn ? (spoilerText && spoilerText.length > 0) : spoiler}
         />
@@ -375,7 +369,6 @@ class ComposeForm extends ImmutablePureComponent {
           onSecondarySubmit={handleSecondarySubmit}
           onSubmit={handleSubmit}
           privacy={privacy}
-          contentType={contentType}
           sideArm={sideArm}
         />
       </div>
diff --git a/app/javascript/flavours/glitch/features/compose/containers/compose_form_container.js b/app/javascript/flavours/glitch/features/compose/containers/compose_form_container.js
index ce5c3afb3..814f9a97a 100644
--- a/app/javascript/flavours/glitch/features/compose/containers/compose_form_container.js
+++ b/app/javascript/flavours/glitch/features/compose/containers/compose_form_container.js
@@ -6,7 +6,6 @@ import {
   changeComposeSpoilerText,
   changeComposeSpoilerness,
   changeComposeVisibility,
-  changeComposeContentType,
   clearComposeSuggestions,
   fetchComposeSuggestions,
   insertEmojiCompose,
@@ -58,7 +57,6 @@ function mapStateToProps (state) {
     media: state.getIn(['compose', 'media_attachments']),
     preselectDate: state.getIn(['compose', 'preselectDate']),
     privacy: state.getIn(['compose', 'privacy']),
-    contentType: state.getIn(['compose', 'content_type']),
     sideArm: sideArmPrivacy,
     sensitive: state.getIn(['compose', 'sensitive']),
     showSearch: state.getIn(['search', 'submitted']) && !state.getIn(['search', 'hidden']),
@@ -100,10 +98,6 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
     dispatch(changeComposeSpoilerText(text));
   },
 
-  onChangeContentType(value) {
-    dispatch(changeComposeContentType(value));
-  },
-
   onPaste(files) {
     dispatch(uploadCompose(files));
   },
diff --git a/app/javascript/flavours/glitch/features/compose/containers/options_container.js b/app/javascript/flavours/glitch/features/compose/containers/options_container.js
index a9ad3a5e8..c8c7ecd43 100644
--- a/app/javascript/flavours/glitch/features/compose/containers/options_container.js
+++ b/app/javascript/flavours/glitch/features/compose/containers/options_container.js
@@ -2,8 +2,10 @@ import { connect } from 'react-redux';
 import Options from '../components/options';
 import {
   changeComposeAdvancedOption,
+  changeComposeContentType,
+  addPoll,
+  removePoll,
 } from 'flavours/glitch/actions/compose';
-import { addPoll, removePoll } from 'flavours/glitch/actions/compose';
 import { closeModal, openModal } from 'flavours/glitch/actions/modal';
 
 function mapStateToProps (state) {
@@ -18,6 +20,7 @@ function mapStateToProps (state) {
     hasMedia: media && !!media.size,
     allowPoll: !(media && !!media.size),
     showContentTypeChoice: state.getIn(['local_settings', 'show_content_type_choice']),
+    contentType: state.getIn(['compose', 'content_type']),
   };
 };
 
@@ -27,6 +30,10 @@ const mapDispatchToProps = (dispatch) => ({
     dispatch(changeComposeAdvancedOption(option, value));
   },
 
+  onChangeContentType(value) {
+    dispatch(changeComposeContentType(value));
+  },
+
   onTogglePoll() {
     dispatch((_, getState) => {
       if (getState().getIn(['compose', 'poll'])) {