From 7b6fe252f18b12107af105f9348da28f2f0d4a0c Mon Sep 17 00:00:00 2001
From: JoramWilander <jwawilander@gmail.com>
Date: Thu, 2 Jul 2015 09:32:31 -0400
Subject: fix getDirectTeammate so that if teammate is the second id it doesn't
 return null

---
 web/react/utils/utils.jsx | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

(limited to 'web/react/utils/utils.jsx')

diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx
index 530166f04..13cb0ff53 100644
--- a/web/react/utils/utils.jsx
+++ b/web/react/utils/utils.jsx
@@ -728,20 +728,22 @@ module.exports.isComment = function(post) {
 }
 
 module.exports.getDirectTeammate = function(channel_id) {
-  var userIds = ChannelStore.get(channel_id).name.split('__');
+    var userIds = ChannelStore.get(channel_id).name.split('__');
+    var curUserId = UserStore.getCurrentId();
+    var teammate = {};
 
-  if(userIds.length != 2) {
-    return;
-  }
-
-  var curUser = UserStore.getCurrentId();
+    if(userIds.length != 2 || userIds.indexOf(curUserId) === -1) {
+        return teammate;
+    }
 
-  for(var idx in userIds) {
-    if(userIds[idx] === curUser)
-      delete userIds[idx];
-  }
+    for (var idx = 0; idx < userIds.length; idx++) {
+        if(userIds[idx] !== curUserId) {
+            teammate = UserStore.getProfile(userIds[idx]);
+            break;
+        }
+    }
 
-  return UserStore.getProfile(userIds[0])
+    return teammate;
 }
 
 Image.prototype.load = function(url, progressCallback) {
-- 
cgit v1.2.3-1-g7c22


From 18629d8184a985d9fe9f9bf892952044b1e5d57f Mon Sep 17 00:00:00 2001
From: JoramWilander <jwawilander@gmail.com>
Date: Thu, 2 Jul 2015 09:34:57 -0400
Subject: make loop simpler

---
 web/react/utils/utils.jsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'web/react/utils/utils.jsx')

diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx
index 13cb0ff53..f8a7d6450 100644
--- a/web/react/utils/utils.jsx
+++ b/web/react/utils/utils.jsx
@@ -736,7 +736,7 @@ module.exports.getDirectTeammate = function(channel_id) {
         return teammate;
     }
 
-    for (var idx = 0; idx < userIds.length; idx++) {
+    for (var idx in userIds) {
         if(userIds[idx] !== curUserId) {
             teammate = UserStore.getProfile(userIds[idx]);
             break;
-- 
cgit v1.2.3-1-g7c22

