From 5574151c8581211326b9ae4dbb400e70b083ecb9 Mon Sep 17 00:00:00 2001
From: JoramWilander <jwawilander@gmail.com>
Date: Fri, 2 Oct 2015 08:14:31 -0400
Subject: Fix postgres query and minor UI updates for outgoing webhooks.

---
 .../components/user_settings/manage_outgoing_hooks.jsx      | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

(limited to 'web/react/components/user_settings/manage_outgoing_hooks.jsx')

diff --git a/web/react/components/user_settings/manage_outgoing_hooks.jsx b/web/react/components/user_settings/manage_outgoing_hooks.jsx
index d8272610d..e83ae3bd6 100644
--- a/web/react/components/user_settings/manage_outgoing_hooks.jsx
+++ b/web/react/components/user_settings/manage_outgoing_hooks.jsx
@@ -39,12 +39,12 @@ export default class ManageOutgoingHooks extends React.Component {
         Client.addOutgoingHook(
             hook,
             (data) => {
-                let hooks = this.state.hooks;
+                let hooks = Object.assign([], this.state.hooks);
                 if (!hooks) {
                     hooks = [];
                 }
                 hooks.push(data);
-                this.setState({hooks, serverError: null});
+                this.setState({hooks, serverError: null, channelId: '', triggerWords: '', callbackURLs: ''});
             },
             (err) => {
                 this.setState({serverError: err});
@@ -93,7 +93,7 @@ export default class ManageOutgoingHooks extends React.Component {
                     }
                 }
 
-                this.setState({hooks});
+                this.setState({hooks, serverError: null});
             },
             (err) => {
                 this.setState({serverError: err});
@@ -103,14 +103,9 @@ export default class ManageOutgoingHooks extends React.Component {
     getHooks() {
         Client.listOutgoingHooks(
             (data) => {
-                const state = this.state;
-
                 if (data) {
-                    state.hooks = data;
+                    this.setState({hooks: data, getHooksComplete: true, serverError: null});
                 }
-
-                state.getHooksComplete = true;
-                this.setState(state);
             },
             (err) => {
                 this.setState({serverError: err});
-- 
cgit v1.2.3-1-g7c22

