From 2b5ec4a3c076bb1f18eeafbd96b0a80c6b8bfbaa Mon Sep 17 00:00:00 2001
From: JoramWilander <jwawilander@gmail.com>
Date: Thu, 15 Oct 2015 10:44:04 -0400
Subject: Small refactor of websocket code on client and server

---
 web/react/components/channel_header.jsx | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)

(limited to 'web/react/components/channel_header.jsx')

diff --git a/web/react/components/channel_header.jsx b/web/react/components/channel_header.jsx
index 7582de6c4..1b709336f 100644
--- a/web/react/components/channel_header.jsx
+++ b/web/react/components/channel_header.jsx
@@ -4,7 +4,6 @@
 const ChannelStore = require('../stores/channel_store.jsx');
 const UserStore = require('../stores/user_store.jsx');
 const PostStore = require('../stores/post_store.jsx');
-const SocketStore = require('../stores/socket_store.jsx');
 const NavbarSearchBox = require('./search_bar.jsx');
 const AsyncClient = require('../utils/async_client.jsx');
 const Client = require('../utils/client.jsx');
@@ -25,7 +24,6 @@ export default class ChannelHeader extends React.Component {
         super(props);
 
         this.onListenerChange = this.onListenerChange.bind(this);
-        this.onSocketChange = this.onSocketChange.bind(this);
         this.handleLeave = this.handleLeave.bind(this);
         this.searchMentions = this.searchMentions.bind(this);
 
@@ -45,7 +43,6 @@ export default class ChannelHeader extends React.Component {
         ChannelStore.addExtraInfoChangeListener(this.onListenerChange);
         PostStore.addSearchChangeListener(this.onListenerChange);
         UserStore.addChangeListener(this.onListenerChange);
-        SocketStore.addChangeListener(this.onSocketChange);
     }
     componentWillUnmount() {
         ChannelStore.removeChangeListener(this.onListenerChange);
@@ -60,16 +57,9 @@ export default class ChannelHeader extends React.Component {
         }
         $('.channel-header__info .description').popover({placement: 'bottom', trigger: 'hover', html: true, delay: {show: 500, hide: 500}});
     }
-    onSocketChange(msg) {
-        if (msg.action === 'new_user' ||
-            msg.action === 'user_added' ||
-            (msg.action === 'user_removed' && msg.user_id !== UserStore.getCurrentId())) {
-            AsyncClient.getChannelExtraInfo(true);
-        }
-    }
     handleLeave() {
         Client.leaveChannel(this.state.channel.id,
-            function handleLeaveSuccess() {
+            () => {
                 AppDispatcher.handleViewAction({
                     type: ActionTypes.LEAVE_CHANNEL,
                     id: this.state.channel.id
@@ -77,8 +67,8 @@ export default class ChannelHeader extends React.Component {
 
                 const townsquare = ChannelStore.getByName('town-square');
                 Utils.switchChannel(townsquare);
-            }.bind(this),
-            function handleLeaveError(err) {
+            },
+            (err) => {
                 AsyncClient.dispatchError(err, 'handleLeave');
             }
         );
-- 
cgit v1.2.3-1-g7c22

