From a65f1fc266f15eaa8f79541d4d11440c3d356bb6 Mon Sep 17 00:00:00 2001
From: Joram Wilander <jwawilander@gmail.com>
Date: Tue, 5 Jul 2016 11:32:37 -0400
Subject: Do not clear the more direct messsages list on every open (#3485)

---
 webapp/components/more_direct_channels.jsx | 47 +++++++++++++-----------------
 1 file changed, 20 insertions(+), 27 deletions(-)

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

diff --git a/webapp/components/more_direct_channels.jsx b/webapp/components/more_direct_channels.jsx
index aaa49571e..c74df5d1d 100644
--- a/webapp/components/more_direct_channels.jsx
+++ b/webapp/components/more_direct_channels.jsx
@@ -1,35 +1,38 @@
 // Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
 // See License.txt for license information.
 
-import {Modal} from 'react-bootstrap';
-import FilteredUserList from './filtered_user_list.jsx';
+import FilteredUserList from 'components/filtered_user_list.jsx';
+import SpinnerButton from 'components/spinner_button.jsx';
+import LoadingScreen from 'components/loading_screen.jsx';
+
+import {getMoreDmList} from 'actions/user_actions.jsx';
+
 import UserStore from 'stores/user_store.jsx';
 import TeamStore from 'stores/team_store.jsx';
+
 import * as Utils from 'utils/utils.jsx';
-import * as GlobalActions from 'actions/global_actions.jsx';
 
+import React from 'react';
+import {Modal} from 'react-bootstrap';
 import {FormattedMessage} from 'react-intl';
 import {browserHistory} from 'react-router/es6';
-import SpinnerButton from 'components/spinner_button.jsx';
-import LoadingScreen from 'components/loading_screen.jsx';
-
-import React from 'react';
 
 export default class MoreDirectChannels extends React.Component {
     constructor(props) {
         super(props);
 
         this.handleHide = this.handleHide.bind(this);
-        this.handleOnEnter = this.handleOnEnter.bind(this);
         this.handleShowDirectChannel = this.handleShowDirectChannel.bind(this);
         this.handleUserChange = this.handleUserChange.bind(this);
         this.onTeamChange = this.onTeamChange.bind(this);
         this.createJoinDirectChannelButton = this.createJoinDirectChannelButton.bind(this);
 
         this.state = {
-            users: null,
-            teamMembers: null,
-            loadingDMChannel: -1
+            users: UserStore.getProfilesForDmList(),
+            teamMembers: TeamStore.getMembersForTeam(),
+            loadingDMChannel: -1,
+            usersLoaded: false,
+            teamMembersLoaded: false
         };
     }
 
@@ -73,17 +76,6 @@ export default class MoreDirectChannels extends React.Component {
         }
     }
 
-    handleOnEnter() {
-        this.setState({
-            users: null,
-            teamMembers: null
-        });
-    }
-
-    handleOnEntered() {
-        GlobalActions.emitProfilesForDmList();
-    }
-
     handleShowDirectChannel(teammate, e) {
         e.preventDefault();
 
@@ -107,13 +99,15 @@ export default class MoreDirectChannels extends React.Component {
 
     handleUserChange() {
         this.setState({
-            users: UserStore.getProfilesForDmList()
+            users: UserStore.getProfilesForDmList(),
+            usersLoaded: true
         });
     }
 
     onTeamChange() {
         this.setState({
-            teamMembers: TeamStore.getMembersForTeam()
+            teamMembers: TeamStore.getMembersForTeam(),
+            teamMembersLoaded: true
         });
     }
 
@@ -139,7 +133,7 @@ export default class MoreDirectChannels extends React.Component {
         }
 
         var body = null;
-        if (this.state.users == null || this.state.teamMembers == null) {
+        if (!this.state.usersLoaded || !this.state.teamMembersLoaded) {
             body = (<LoadingScreen/>);
         } else {
             var showTeamToggle = false;
@@ -163,8 +157,7 @@ export default class MoreDirectChannels extends React.Component {
                 dialogClassName='more-modal more-direct-channels'
                 show={this.props.show}
                 onHide={this.handleHide}
-                onEnter={this.handleOnEnter}
-                onEntered={this.handleOnEntered}
+                onEntered={getMoreDmList}
             >
                 <Modal.Header closeButton={true}>
                     <Modal.Title>
-- 
cgit v1.2.3-1-g7c22

