Fixes composer mounting issue with #293

pull/296/head
kibigo! 2018-01-05 18:30:06 -08:00
parent 03aeab857f
commit 8bf9d9362a
1 changed files with 22 additions and 0 deletions

View File

@ -15,10 +15,12 @@ import {
clearComposeSuggestions, clearComposeSuggestions,
fetchComposeSuggestions, fetchComposeSuggestions,
insertEmojiCompose, insertEmojiCompose,
mountCompose,
selectComposeSuggestion, selectComposeSuggestion,
submitCompose, submitCompose,
toggleComposeAdvancedOption, toggleComposeAdvancedOption,
undoUploadCompose, undoUploadCompose,
unmountCompose,
uploadCompose, uploadCompose,
} from 'flavours/glitch/actions/compose'; } from 'flavours/glitch/actions/compose';
import { import {
@ -84,12 +86,14 @@ const mapDispatchToProps = {
onCloseModal: closeModal, onCloseModal: closeModal,
onFetchSuggestions: fetchComposeSuggestions, onFetchSuggestions: fetchComposeSuggestions,
onInsertEmoji: insertEmojiCompose, onInsertEmoji: insertEmojiCompose,
onMount: mountCompose,
onOpenActionsModal: openModal.bind(null, 'ACTIONS'), onOpenActionsModal: openModal.bind(null, 'ACTIONS'),
onOpenDoodleModal: openModal.bind(null, 'DOODLE', { noEsc: true }), onOpenDoodleModal: openModal.bind(null, 'DOODLE', { noEsc: true }),
onSelectSuggestion: selectComposeSuggestion, onSelectSuggestion: selectComposeSuggestion,
onSubmit: submitCompose, onSubmit: submitCompose,
onToggleAdvancedOption: toggleComposeAdvancedOption, onToggleAdvancedOption: toggleComposeAdvancedOption,
onUndoUpload: undoUploadCompose, onUndoUpload: undoUploadCompose,
onUnmount: unmountCompose,
onUpload: uploadCompose, 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: // This statement does several things:
// - If we're beginning a reply, and, // - If we're beginning a reply, and,
// - Replying to zero or one users, places the cursor at the end // - Replying to zero or one users, places the cursor at the end
@ -409,12 +429,14 @@ Composer.propTypes = {
onCloseModal: PropTypes.func, onCloseModal: PropTypes.func,
onFetchSuggestions: PropTypes.func, onFetchSuggestions: PropTypes.func,
onInsertEmoji: PropTypes.func, onInsertEmoji: PropTypes.func,
onMount: PropTypes.func,
onOpenActionsModal: PropTypes.func, onOpenActionsModal: PropTypes.func,
onOpenDoodleModal: PropTypes.func, onOpenDoodleModal: PropTypes.func,
onSelectSuggestion: PropTypes.func, onSelectSuggestion: PropTypes.func,
onSubmit: PropTypes.func, onSubmit: PropTypes.func,
onToggleAdvancedOption: PropTypes.func, onToggleAdvancedOption: PropTypes.func,
onUndoUpload: PropTypes.func, onUndoUpload: PropTypes.func,
onUnmount: PropTypes.func,
onUpload: PropTypes.func, onUpload: PropTypes.func,
}; };