From 1fa3f2351c98e4d1b9c198e357d90ac0d436dcaa Mon Sep 17 00:00:00 2001
From: George Goldberg <george@gberg.me>
Date: Tue, 4 Apr 2017 20:17:15 +0100
Subject: PLT-6023: Add Users to Team in WebApp. (#5956)

* PLT-6198: Use added to channel system message on default channels.

Use a different sytem message when a user was added to a default channel
by someone else than when they joined themselves.

* PLT-6023: Add Users to Team in WebApp.

* Fix string text.

* Handle added_to_team websocket message.

* Fix unread flag on new channel.
---
 webapp/utils/async_client.jsx | 58 ++++++++++++++++++++++---------------------
 1 file changed, 30 insertions(+), 28 deletions(-)

(limited to 'webapp/utils/async_client.jsx')

diff --git a/webapp/utils/async_client.jsx b/webapp/utils/async_client.jsx
index b4b361cb4..faaf3aee6 100644
--- a/webapp/utils/async_client.jsx
+++ b/webapp/utils/async_client.jsx
@@ -403,6 +403,36 @@ export function getProfilesInTeam(teamId = TeamStore.getCurrentId(), offset = Us
     );
 }
 
+export function getProfilesNotInTeam(teamId = TeamStore.getCurrentId(), offset = UserStore.getInTeamPagingOffset(), limit = Constants.PROFILE_CHUNK_SIZE) {
+    const callName = `getProfilesNotInTeam${teamId}${offset}${limit}`;
+
+    if (isCallInProgress(callName)) {
+        return;
+    }
+
+    callTracker[callName] = utils.getTimestamp();
+    Client.getProfilesNotInTeam(
+        teamId,
+        offset,
+        limit,
+        (data) => {
+            callTracker[callName] = 0;
+
+            AppDispatcher.handleServerAction({
+                type: ActionTypes.RECEIVED_PROFILES_NOT_IN_TEAM,
+                profiles: data,
+                team_id: teamId,
+                offset,
+                count: Object.keys(data).length
+            });
+        },
+        (err) => {
+            callTracker[callName] = 0;
+            dispatchError(err, 'getProfilesNotInTeam');
+        }
+    );
+}
+
 export function getProfilesInChannel(channelId = ChannelStore.getCurrentId(), offset = UserStore.getInChannelPagingOffset(), limit = Constants.PROFILE_CHUNK_SIZE) {
     const callName = `getProfilesInChannel${channelId}${offset}${limit}`;
 
@@ -830,34 +860,6 @@ export function getTeamMember(teamId, userId) {
     );
 }
 
-export function getMyTeamMembers() {
-    const callName = 'getMyTeamMembers';
-    if (isCallInProgress(callName)) {
-        return;
-    }
-
-    callTracker[callName] = utils.getTimestamp();
-    Client.getMyTeamMembers(
-        (data) => {
-            callTracker[callName] = 0;
-
-            const members = {};
-            for (const member of data) {
-                members[member.team_id] = member;
-            }
-
-            AppDispatcher.handleServerAction({
-                type: ActionTypes.RECEIVED_MY_TEAM_MEMBERS_UNREAD,
-                team_members: members
-            });
-        },
-        (err) => {
-            callTracker[callName] = 0;
-            dispatchError(err, 'getMyTeamMembers');
-        }
-    );
-}
-
 export function getMyTeamsUnread(teamId) {
     const members = TeamStore.getMyTeamMembers();
     if (members.length > 1) {
-- 
cgit v1.2.3-1-g7c22

