Browse Source

Improved updates handling

master
Igor Zhukov 9 years ago
parent
commit
2ed0cc6074
  1. 2
      app/js/message_composer.js
  2. 24
      app/js/services.js

2
app/js/message_composer.js

@ -585,7 +585,7 @@ EmojiTooltip.prototype.activateStickerCategory = function () {
var viewportWidth = categoriesEl.clientWidth; var viewportWidth = categoriesEl.clientWidth;
// console.log('current cat el', categoryEl, left, width, viewportWidth); // console.log('current cat el', categoryEl, left, width, viewportWidth);
$(categoriesEl).animate({scrollLeft: left - (viewportWidth - width) / 2}, 200); $(categoriesEl).stop(true).animate({scrollLeft: left - (viewportWidth - width) / 2}, 200);
} }

24
app/js/services.js

@ -2797,13 +2797,14 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
// Should be first because of updateMessageID // Should be first because of updateMessageID
// console.log(dT(), 'applying', differenceResult.other_updates.length, 'other updates'); // console.log(dT(), 'applying', differenceResult.other_updates.length, 'other updates');
var channelsUpdates = [];
angular.forEach(differenceResult.other_updates, function(update) { angular.forEach(differenceResult.other_updates, function(update) {
if (update._ == 'updateChannelTooLong') { switch (update._) {
var channelID = update.channel_id; case 'updateChannelTooLong':
var channelState = channelStates[channelID]; case 'updateNewChannelMessage':
if (channelState !== undefined && !channelState.syncLoading) { case 'updateEditChannelMessage':
getChannelDifference(channelID); processUpdate(update);
}
return; return;
} }
saveUpdate(update); saveUpdate(update);
@ -2927,6 +2928,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
} }
function processUpdate (update, options) { function processUpdate (update, options) {
options = options || {};
var channelID = false; var channelID = false;
switch (update._) { switch (update._) {
case 'updateNewChannelMessage': case 'updateNewChannelMessage':
@ -2935,6 +2937,12 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
case 'updateDeleteChannelMessages': case 'updateDeleteChannelMessages':
channelID = update.channel_id; channelID = update.channel_id;
break; break;
case 'updateChannelTooLong':
channelID = update.channel_id;
if (channelStates[channelID] === undefined) {
return false;
}
break;
} }
if (channelID && !AppChatsManager.hasChat(channelID)) { if (channelID && !AppChatsManager.hasChat(channelID)) {
// console.log(dT(), 'skip update, missing channel', channelID, update); // console.log(dT(), 'skip update, missing channel', channelID, update);
@ -2963,6 +2971,10 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
return false; return false;
} }
} }
if (update._ == 'updateChannelTooLong' &&
!channelState.syncLoading) {
getChannelDifference(channelID);
}
var popPts, popSeq; var popPts, popSeq;

Loading…
Cancel
Save