From 54a064de98f43c55bed429867493e6f5c7e97379 Mon Sep 17 00:00:00 2001
From: Christopher Speller <crspeller@gmail.com>
Date: Thu, 31 Mar 2016 10:54:40 -0400
Subject: Fixing username display in center channel

---
 webapp/components/invite_member_modal.jsx | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

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

diff --git a/webapp/components/invite_member_modal.jsx b/webapp/components/invite_member_modal.jsx
index 1f8fd6133..81c3a9629 100644
--- a/webapp/components/invite_member_modal.jsx
+++ b/webapp/components/invite_member_modal.jsx
@@ -50,6 +50,7 @@ class InviteMemberModal extends React.Component {
     constructor(props) {
         super(props);
 
+        this.teamChange = this.teamChange.bind(this);
         this.handleToggle = this.handleToggle.bind(this);
         this.handleSubmit = this.handleSubmit.bind(this);
         this.handleHide = this.handleHide.bind(this);
@@ -68,16 +69,27 @@ class InviteMemberModal extends React.Component {
             emailEnabled: global.window.mm_config.SendEmailNotifications === 'true',
             userCreationEnabled: global.window.mm_config.EnableUserCreation === 'true',
             showConfirmModal: false,
-            isSendingEmails: false
+            isSendingEmails: false,
+            teamType: null
         };
     }
 
+    teamChange() {
+        const team = TeamStore.getCurrent();
+        const teamType = team ? team.type : null;
+        this.setState({
+            teamType
+        });
+    }
+
     componentDidMount() {
         ModalStore.addModalListener(ActionTypes.TOGGLE_INVITE_MEMBER_MODAL, this.handleToggle);
+        TeamStore.addChangeListener(this.teamChange);
     }
 
     componentWillUnmount() {
         ModalStore.removeModalListener(ActionTypes.TOGGLE_INVITE_MEMBER_MODAL, this.handleToggle);
+        TeamStore.removeChangeListener(this.teamChange);
     }
 
     handleToggle(value) {
@@ -224,7 +236,7 @@ class InviteMemberModal extends React.Component {
         var currentUser = UserStore.getCurrentUser();
         const {formatMessage} = this.props.intl;
 
-        if (currentUser != null) {
+        if (currentUser != null && this.state.teamType != null) {
             var inviteSections = [];
             var inviteIds = this.state.inviteIds;
             for (var i = 0; i < inviteIds.length; i++) {
@@ -398,7 +410,7 @@ class InviteMemberModal extends React.Component {
                 );
             } else if (this.state.userCreationEnabled) {
                 var teamInviteLink = null;
-                if (currentUser && TeamStore.getCurrent().type === 'O') {
+                if (currentUser && this.state.teamType === 'O') {
                     var link = (
                         <a
                             href='#'
-- 
cgit v1.2.3-1-g7c22

