|
|
@ -750,50 +750,6 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) |
|
|
|
$rootScope.$on('apiUpdate', function (e, update) { |
|
|
|
$rootScope.$on('apiUpdate', function (e, update) { |
|
|
|
// console.log('on apiUpdate', update);
|
|
|
|
// console.log('on apiUpdate', update);
|
|
|
|
switch (update._) { |
|
|
|
switch (update._) { |
|
|
|
case 'updateChatParticipants': |
|
|
|
|
|
|
|
var participants = update.participants; |
|
|
|
|
|
|
|
var chatFull = chatsFull[participants.id]; |
|
|
|
|
|
|
|
if (chatFull !== undefined) { |
|
|
|
|
|
|
|
chatFull.participants = update.participants; |
|
|
|
|
|
|
|
$rootScope.$broadcast('chat_full_update', chatID); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'updateChatParticipantAdd': |
|
|
|
|
|
|
|
var chatFull = chatsFull[update.chat_id]; |
|
|
|
|
|
|
|
if (chatFull !== undefined) { |
|
|
|
|
|
|
|
var participants = chatFull.participants.participants || []; |
|
|
|
|
|
|
|
for (var i = 0, length = participants.length; i < length; i++) { |
|
|
|
|
|
|
|
if (participants[i].user_id == update.user_id) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
participants.push({ |
|
|
|
|
|
|
|
_: 'chatParticipant', |
|
|
|
|
|
|
|
user_id: update.user_id, |
|
|
|
|
|
|
|
inviter_id: update.inviter_id, |
|
|
|
|
|
|
|
date: tsNow(true) |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
chatFull.participants.version = update.version; |
|
|
|
|
|
|
|
$rootScope.$broadcast('chat_full_update', update.chat_id); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'updateChatParticipantDelete': |
|
|
|
|
|
|
|
var chatFull = chatsFull[update.chat_id]; |
|
|
|
|
|
|
|
if (chatFull !== undefined) { |
|
|
|
|
|
|
|
var participants = chatFull.participants.participants || []; |
|
|
|
|
|
|
|
for (var i = 0, length = participants.length; i < length; i++) { |
|
|
|
|
|
|
|
if (participants[i].user_id == update.user_id) { |
|
|
|
|
|
|
|
participants.splice(i, 1); |
|
|
|
|
|
|
|
chatFull.participants.version = update.version; |
|
|
|
|
|
|
|
$rootScope.$broadcast('chat_full_update', update.chat_id); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'updateChannel': |
|
|
|
case 'updateChannel': |
|
|
|
var channelID = update.channel_id; |
|
|
|
var channelID = update.channel_id; |
|
|
|
$rootScope.$broadcast('channel_settings', {channelID: channelID}); |
|
|
|
$rootScope.$broadcast('channel_settings', {channelID: channelID}); |
|
|
@ -1153,6 +1109,56 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$rootScope.$on('apiUpdate', function (e, update) { |
|
|
|
|
|
|
|
// console.log('on apiUpdate', update);
|
|
|
|
|
|
|
|
switch (update._) { |
|
|
|
|
|
|
|
case 'updateChatParticipants': |
|
|
|
|
|
|
|
var participants = update.participants; |
|
|
|
|
|
|
|
var chatFull = chatsFull[participants.id]; |
|
|
|
|
|
|
|
if (chatFull !== undefined) { |
|
|
|
|
|
|
|
chatFull.participants = update.participants; |
|
|
|
|
|
|
|
$rootScope.$broadcast('chat_full_update', chatID); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'updateChatParticipantAdd': |
|
|
|
|
|
|
|
var chatFull = chatsFull[update.chat_id]; |
|
|
|
|
|
|
|
if (chatFull !== undefined) { |
|
|
|
|
|
|
|
var participants = chatFull.participants.participants || []; |
|
|
|
|
|
|
|
for (var i = 0, length = participants.length; i < length; i++) { |
|
|
|
|
|
|
|
if (participants[i].user_id == update.user_id) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
participants.push({ |
|
|
|
|
|
|
|
_: 'chatParticipant', |
|
|
|
|
|
|
|
user_id: update.user_id, |
|
|
|
|
|
|
|
inviter_id: update.inviter_id, |
|
|
|
|
|
|
|
date: tsNow(true) |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
chatFull.participants.version = update.version; |
|
|
|
|
|
|
|
$rootScope.$broadcast('chat_full_update', update.chat_id); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'updateChatParticipantDelete': |
|
|
|
|
|
|
|
var chatFull = chatsFull[update.chat_id]; |
|
|
|
|
|
|
|
if (chatFull !== undefined) { |
|
|
|
|
|
|
|
var participants = chatFull.participants.participants || []; |
|
|
|
|
|
|
|
for (var i = 0, length = participants.length; i < length; i++) { |
|
|
|
|
|
|
|
if (participants[i].user_id == update.user_id) { |
|
|
|
|
|
|
|
participants.splice(i, 1); |
|
|
|
|
|
|
|
chatFull.participants.version = update.version; |
|
|
|
|
|
|
|
$rootScope.$broadcast('chat_full_update', update.chat_id); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
return { |
|
|
|
getPeerBots: getPeerBots, |
|
|
|
getPeerBots: getPeerBots, |
|
|
|
getProfile: getProfile, |
|
|
|
getProfile: getProfile, |
|
|
|