From 5be6661f12171b6e09bccfc32c1b46ef042f46ac Mon Sep 17 00:00:00 2001
From: David Lu <david.lu@hotmail.com>
Date: Mon, 27 Jun 2016 08:13:16 -0400
Subject: PLT-3332 Removed multiple change channel header messages (#3390)

* disabled submit upon form submission to avoid asynchronous errors

* Used state instead of props
---
 webapp/components/edit_channel_header_modal.jsx | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

(limited to 'webapp/components/edit_channel_header_modal.jsx')

diff --git a/webapp/components/edit_channel_header_modal.jsx b/webapp/components/edit_channel_header_modal.jsx
index d7ef1d81f..394c0e21c 100644
--- a/webapp/components/edit_channel_header_modal.jsx
+++ b/webapp/components/edit_channel_header_modal.jsx
@@ -36,7 +36,8 @@ class EditChannelHeaderModal extends React.Component {
 
         this.state = {
             header: props.channel.header,
-            serverError: ''
+            serverError: '',
+            submitted: false
         };
     }
 
@@ -55,7 +56,8 @@ class EditChannelHeaderModal extends React.Component {
     componentWillReceiveProps(nextProps) {
         if (this.props !== nextProps) {
             this.setState({
-                header: nextProps.channel.header
+                header: nextProps.channel.header,
+                submitted: false
             });
         }
     }
@@ -77,6 +79,8 @@ class EditChannelHeaderModal extends React.Component {
     }
 
     handleSubmit() {
+        this.setState({submitted: true});
+
         Client.updateChannelHeader(
             this.props.channel.id,
             this.state.header,
@@ -102,6 +106,7 @@ class EditChannelHeaderModal extends React.Component {
     onShow() {
         const textarea = ReactDOM.findDOMNode(this.refs.textarea);
         Utils.placeCaretAtEnd(textarea);
+        this.submitted = false;
     }
 
     onHide() {
@@ -190,6 +195,7 @@ class EditChannelHeaderModal extends React.Component {
                         />
                     </button>
                     <button
+                        disabled={this.state.submitted}
                         type='button'
                         className='btn btn-primary'
                         onClick={this.handleSubmit}
-- 
cgit v1.2.3-1-g7c22

