From 86fbd496af8ff646bcff8484ad1733101333e8c6 Mon Sep 17 00:00:00 2001
From: Joram Wilander <jwawilander@gmail.com>
Date: Fri, 7 Apr 2017 14:21:31 -0400
Subject: Check if we need to add DM/GM to sidebar regardless of post sender
 (#6009)

---
 webapp/actions/user_actions.jsx | 49 +++++++++++++++++++++++++++++------------
 1 file changed, 35 insertions(+), 14 deletions(-)

(limited to 'webapp/actions/user_actions.jsx')

diff --git a/webapp/actions/user_actions.jsx b/webapp/actions/user_actions.jsx
index 1ab85922d..70df4776e 100644
--- a/webapp/actions/user_actions.jsx
+++ b/webapp/actions/user_actions.jsx
@@ -11,7 +11,7 @@ import ChannelStore from 'stores/channel_store.jsx';
 import {getChannelMembersForUserIds} from 'actions/channel_actions.jsx';
 import {loadStatusesForProfilesList, loadStatusesForProfilesMap} from 'actions/status_actions.jsx';
 
-import {getDirectChannelName} from 'utils/utils.jsx';
+import {getDirectChannelName, getUserIdFromChannelName} from 'utils/utils.jsx';
 
 import * as AsyncClient from 'utils/async_client.jsx';
 import Client from 'client/web_client.jsx';
@@ -255,24 +255,45 @@ function populateChannelWithProfiles(channelId, userIds) {
     UserStore.emitInChannelChange();
 }
 
-export function loadNewDMIfNeeded(userId) {
-    if (userId === UserStore.getCurrentId()) {
-        return;
-    }
+export function loadNewDMIfNeeded(channelId) {
+    function checkPreference(channel) {
+        const userId = getUserIdFromChannelName(channel);
+
+        if (!userId) {
+            return;
+        }
 
-    const pref = PreferenceStore.getBool(Preferences.CATEGORY_DIRECT_CHANNEL_SHOW, userId, false);
-    if (pref === false) {
-        PreferenceStore.setPreference(Preferences.CATEGORY_DIRECT_CHANNEL_SHOW, userId, 'true');
-        AsyncClient.savePreference(Preferences.CATEGORY_DIRECT_CHANNEL_SHOW, userId, 'true');
-        loadProfilesForDM();
+        const pref = PreferenceStore.getBool(Preferences.CATEGORY_DIRECT_CHANNEL_SHOW, userId, false);
+        if (pref === false) {
+            PreferenceStore.setPreference(Preferences.CATEGORY_DIRECT_CHANNEL_SHOW, userId, 'true');
+            AsyncClient.savePreference(Preferences.CATEGORY_DIRECT_CHANNEL_SHOW, userId, 'true');
+            loadProfilesForDM();
+        }
     }
-}
 
-export function loadNewGMIfNeeded(channelId, userId) {
-    if (userId === UserStore.getCurrentId()) {
-        return;
+    const channel = ChannelStore.get(channelId);
+    if (channel) {
+        checkPreference(channel);
+    } else {
+        Client.getChannel(
+            channelId,
+            (data) => {
+                AppDispatcher.handleServerAction({
+                    type: ActionTypes.RECEIVED_CHANNEL,
+                    channel: data.channel,
+                    member: data.member
+                });
+
+                checkPreference(data.channel);
+            },
+            (err) => {
+                AsyncClient.dispatchError(err, 'getChannel');
+            }
+       );
     }
+}
 
+export function loadNewGMIfNeeded(channelId) {
     function checkPreference() {
         const pref = PreferenceStore.getBool(Preferences.CATEGORY_GROUP_CHANNEL_SHOW, channelId, false);
         if (pref === false) {
-- 
cgit v1.2.3-1-g7c22


From 9c3b96661bfe358cfad2b7ceb43b40fee6f3c544 Mon Sep 17 00:00:00 2001
From: George Goldberg <george@gberg.me>
Date: Mon, 10 Apr 2017 17:21:54 +0100
Subject: PLT-6253: Handle demote self from Team Admin. (#6056)

---
 webapp/actions/user_actions.jsx | 12 ++++++++++++
 1 file changed, 12 insertions(+)

(limited to 'webapp/actions/user_actions.jsx')

diff --git a/webapp/actions/user_actions.jsx b/webapp/actions/user_actions.jsx
index 70df4776e..ecbe83feb 100644
--- a/webapp/actions/user_actions.jsx
+++ b/webapp/actions/user_actions.jsx
@@ -953,3 +953,15 @@ export function getMissingProfiles(ids, success, error) {
 
     AsyncClient.getProfilesByIds(missingIds, success, error);
 }
+
+export function loadMyTeamMembers() {
+    Client.getMyTeamMembers((data) => {
+        AppDispatcher.handleServerAction({
+            type: ActionTypes.RECEIVED_MY_TEAM_MEMBERS,
+            team_members: data
+        });
+        AsyncClient.getMyTeamsUnread();
+    }, (err) => {
+        AsyncClient.dispatchError(err, 'getMyTeamMembers');
+    });
+}
-- 
cgit v1.2.3-1-g7c22

