about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorkibigo! <marrus-sh@users.noreply.github.com>2018-01-05 18:30:06 -0800
committerkibigo! <marrus-sh@users.noreply.github.com>2018-01-05 18:30:06 -0800
commit8bf9d9362a4eeb774d849887c1645b3175d73828 (patch)
tree5cdbf0e7256e6a9b257b37f69109a90d3d323b77 /app
parent03aeab857f0972e74910307f1a5954353eb70a28 (diff)
Fixes composer mounting issue with #293
Diffstat (limited to 'app')
-rw-r--r--app/javascript/flavours/glitch/features/composer/index.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/app/javascript/flavours/glitch/features/composer/index.js b/app/javascript/flavours/glitch/features/composer/index.js
index d64bee7ee..4c9d4b197 100644
--- a/app/javascript/flavours/glitch/features/composer/index.js
+++ b/app/javascript/flavours/glitch/features/composer/index.js
@@ -15,10 +15,12 @@ import {
   clearComposeSuggestions,
   fetchComposeSuggestions,
   insertEmojiCompose,
+  mountCompose,
   selectComposeSuggestion,
   submitCompose,
   toggleComposeAdvancedOption,
   undoUploadCompose,
+  unmountCompose,
   uploadCompose,
 } from 'flavours/glitch/actions/compose';
 import {
@@ -84,12 +86,14 @@ const mapDispatchToProps = {
   onCloseModal: closeModal,
   onFetchSuggestions: fetchComposeSuggestions,
   onInsertEmoji: insertEmojiCompose,
+  onMount: mountCompose,
   onOpenActionsModal: openModal.bind(null, 'ACTIONS'),
   onOpenDoodleModal: openModal.bind(null, 'DOODLE', { noEsc: true }),
   onSelectSuggestion: selectComposeSuggestion,
   onSubmit: submitCompose,
   onToggleAdvancedOption: toggleComposeAdvancedOption,
   onUndoUpload: undoUploadCompose,
+  onUnmount: unmountCompose,
   onUpload: uploadCompose,
 };
 
@@ -188,6 +192,22 @@ class Composer extends React.Component {
     }
   }
 
+  //  Tells our state the composer has been mounted.
+  componentDidMount () {
+    const { onMount } = this.props;
+    if (onMount) {
+      onMount();
+    }
+  }
+
+  //  Tells our state the composer has been unmounted.
+  componentWillUnmount () {
+    const { onUnmount } = this.props;
+    if (onUnmount) {
+      onUnmount();
+    }
+  }
+
   //  This statement does several things:
   //  - If we're beginning a reply, and,
   //      - Replying to zero or one users, places the cursor at the end
@@ -409,12 +429,14 @@ Composer.propTypes = {
   onCloseModal: PropTypes.func,
   onFetchSuggestions: PropTypes.func,
   onInsertEmoji: PropTypes.func,
+  onMount: PropTypes.func,
   onOpenActionsModal: PropTypes.func,
   onOpenDoodleModal: PropTypes.func,
   onSelectSuggestion: PropTypes.func,
   onSubmit: PropTypes.func,
   onToggleAdvancedOption: PropTypes.func,
   onUndoUpload: PropTypes.func,
+  onUnmount: PropTypes.func,
   onUpload: PropTypes.func,
 };