Browse Source

Improved updates handling

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

2
app/js/message_composer.js

@ -585,7 +585,7 @@ EmojiTooltip.prototype.activateStickerCategory = function () { @@ -585,7 +585,7 @@ EmojiTooltip.prototype.activateStickerCategory = function () {
var viewportWidth = categoriesEl.clientWidth;
// 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);
}

26
app/js/services.js

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

Loading…
Cancel
Save