fix getDirectTeammate so that if teammate is the second id it doesn't return null

Этот коммит содержится в:
JoramWilander
2015-07-02 09:32:31 -04:00
родитель bd9b038c00
Коммит 7b6fe252f1

Просмотреть файл

@@ -729,19 +729,21 @@ module.exports.isComment = function(post) {
module.exports.getDirectTeammate = function(channel_id) { 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) { if(userIds.length != 2 || userIds.indexOf(curUserId) === -1) {
return; return teammate;
} }
var curUser = UserStore.getCurrentId(); for (var idx = 0; idx < userIds.length; idx++) {
if(userIds[idx] !== curUserId) {
for(var idx in userIds) { teammate = UserStore.getProfile(userIds[idx]);
if(userIds[idx] === curUser) break;
delete userIds[idx]; }
} }
return UserStore.getProfile(userIds[0]) return teammate;
} }
Image.prototype.load = function(url, progressCallback) { Image.prototype.load = function(url, progressCallback) {