diff options
author | Nick Frazier <nrflaw@gmail.com> | 2016-12-26 09:25:50 -0500 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2016-12-26 09:25:50 -0500 |
commit | 0a1b0d051a1a7d83ad01502f8073d35ee5da95cc (patch) | |
tree | 24901635fc7bc3bc78f45efd4a92d943ba2efc54 /webapp/components/create_post.jsx | |
parent | 87d84dfc30d30a24af35411bac7dafb188575749 (diff) | |
download | chat-0a1b0d051a1a7d83ad01502f8073d35ee5da95cc.tar.gz chat-0a1b0d051a1a7d83ad01502f8073d35ee5da95cc.tar.bz2 chat-0a1b0d051a1a7d83ad01502f8073d35ee5da95cc.zip |
Add error to RHS reply box for messages > 4000 chars, consistent with create post and edit post errors (#4871)
* functionality
* CSS updates
* cleanup
* moved message length checks to Textbox component
* cleanup
Diffstat (limited to 'webapp/components/create_post.jsx')
-rw-r--r-- | webapp/components/create_post.jsx | 30 |
1 files changed, 7 insertions, 23 deletions
diff --git a/webapp/components/create_post.jsx b/webapp/components/create_post.jsx index 5346d05ad..8e75b6070 100644 --- a/webapp/components/create_post.jsx +++ b/webapp/components/create_post.jsx @@ -25,7 +25,7 @@ import PreferenceStore from 'stores/preference_store.jsx'; import Constants from 'utils/constants.jsx'; -import {FormattedHTMLMessage, FormattedMessage} from 'react-intl'; +import {FormattedHTMLMessage} from 'react-intl'; import {browserHistory} from 'react-router/es6'; const Preferences = Constants.Preferences; @@ -61,7 +61,7 @@ export default class CreatePost extends React.Component { this.showPostDeletedModal = this.showPostDeletedModal.bind(this); this.hidePostDeletedModal = this.hidePostDeletedModal.bind(this); this.showShortcuts = this.showShortcuts.bind(this); - this.checkMessageLength = this.checkMessageLength.bind(this); + this.handlePostError = this.handlePostError.bind(this); PostStore.clearDraftUploads(); @@ -81,6 +81,10 @@ export default class CreatePost extends React.Component { }; } + handlePostError(postError) { + this.setState({postError}); + } + handleSubmit(e) { e.preventDefault(); @@ -218,25 +222,6 @@ export default class CreatePost extends React.Component { const draft = PostStore.getCurrentDraft(); draft.message = message; PostStore.storeCurrentDraft(draft); - - this.checkMessageLength(message); - } - - checkMessageLength(message) { - if (message.length > Constants.CHARACTER_LIMIT) { - const errorMessage = ( - <FormattedMessage - id='create_post.error_message' - defaultMessage='Your message is too long. Character count: {length}/{limit}' - values={{ - length: message.length, - limit: Constants.CHARACTER_LIMIT - }} - />); - this.setState({postError: errorMessage}); - } else { - this.setState({postError: null}); - } } handleUploadClick() { @@ -335,8 +320,6 @@ export default class CreatePost extends React.Component { fullWidthTextBox: PreferenceStore.get(Preferences.CATEGORY_DISPLAY_SETTINGS, Preferences.CHANNEL_DISPLAY_MODE, Preferences.CHANNEL_DISPLAY_MODE_DEFAULT) === Preferences.CHANNEL_DISPLAY_MODE_FULL_SCREEN, showTutorialTip: tutorialStep === TutorialSteps.POST_POPOVER }); - - this.checkMessageLength(this.state.message); } componentDidMount() { @@ -543,6 +526,7 @@ export default class CreatePost extends React.Component { onChange={this.handleChange} onKeyPress={this.postMsgKeyPress} onKeyDown={this.handleKeyDown} + handlePostError={this.handlePostError} value={this.state.message} onBlur={this.handleBlur} createMessage={Utils.localizeMessage('create_post.write', 'Write a message...')} |