From 1b141681ae6a169272003fa83fb83ba245dbafc7 Mon Sep 17 00:00:00 2001
From: Joram Wilander <jwawilander@gmail.com>
Date: Thu, 3 Nov 2016 11:23:57 -0400
Subject: Add status listeners back to user list modals (#4428)

---
 webapp/components/channel_invite_modal.jsx | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

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

diff --git a/webapp/components/channel_invite_modal.jsx b/webapp/components/channel_invite_modal.jsx
index 7f6ca4d32..576a33dc5 100644
--- a/webapp/components/channel_invite_modal.jsx
+++ b/webapp/components/channel_invite_modal.jsx
@@ -25,6 +25,7 @@ export default class ChannelInviteModal extends React.Component {
         super(props);
 
         this.onChange = this.onChange.bind(this);
+        this.onStatusChange = this.onStatusChange.bind(this);
         this.handleInviteError = this.handleInviteError.bind(this);
         this.nextPage = this.nextPage.bind(this);
         this.search = this.search.bind(this);
@@ -37,7 +38,8 @@ export default class ChannelInviteModal extends React.Component {
         this.state = {
             users: [],
             total: teamStats.member_count - channelStats.member_count,
-            search: false
+            search: false,
+            statusChange: false
         };
     }
 
@@ -46,6 +48,7 @@ export default class ChannelInviteModal extends React.Component {
             TeamStore.addStatsChangeListener(this.onChange);
             ChannelStore.addStatsChangeListener(this.onChange);
             UserStore.addNotInChannelChangeListener(this.onChange);
+            UserStore.addStatusesChangeListener(this.onStatusChange);
 
             this.onChange();
             AsyncClient.getProfilesNotInChannel(this.props.channel.id, 0);
@@ -54,6 +57,7 @@ export default class ChannelInviteModal extends React.Component {
             TeamStore.removeStatsChangeListener(this.onChange);
             ChannelStore.removeStatsChangeListener(this.onChange);
             UserStore.removeNotInChannelChangeListener(this.onChange);
+            UserStore.removeStatusesChangeListener(this.onStatusChange);
         }
     }
 
@@ -61,10 +65,11 @@ export default class ChannelInviteModal extends React.Component {
         ChannelStore.removeStatsChangeListener(this.onChange);
         ChannelStore.removeChangeListener(this.onChange);
         UserStore.removeNotInChannelChangeListener(this.onChange);
+        UserStore.removeStatusesChangeListener(this.onStatusChange);
     }
 
-    onChange() {
-        if (this.state.search) {
+    onChange(force) {
+        if (this.state.search && !force) {
             this.search(this.term);
             return;
         }
@@ -78,6 +83,13 @@ export default class ChannelInviteModal extends React.Component {
         });
     }
 
+    onStatusChange() {
+        // Initiate a render to pick up on new statuses
+        this.setState({
+            statusChange: !this.state.statusChange
+        });
+    }
+
     handleInviteError(err) {
         if (err) {
             this.setState({
@@ -98,7 +110,8 @@ export default class ChannelInviteModal extends React.Component {
         this.term = term;
 
         if (term === '') {
-            this.setState({users: UserStore.getProfileListNotInChannel(), search: false});
+            this.onChange(true);
+            this.setState({search: false});
             return;
         }
 
-- 
cgit v1.2.3-1-g7c22

