diff options
Diffstat (limited to 'web/react/utils/utils.jsx')
-rw-r--r-- | web/react/utils/utils.jsx | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx index 530166f04..f8a7d6450 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 in userIds) { + if(userIds[idx] !== curUserId) { + teammate = UserStore.getProfile(userIds[idx]); + break; + } + } - return UserStore.getProfile(userIds[0]) + return teammate; } Image.prototype.load = function(url, progressCallback) { |