From 2ed0cc60740e18fc64f70e44bff52d9486ea5ad7 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Tue, 12 Apr 2016 00:50:32 +0300 Subject: [PATCH] Improved updates handling --- app/js/message_composer.js | 2 +- app/js/services.js | 26 +++++++++++++++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/app/js/message_composer.js b/app/js/message_composer.js index b4392031..530b361b 100644 --- a/app/js/message_composer.js +++ b/app/js/message_composer.js @@ -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); } diff --git a/app/js/services.js b/app/js/services.js index f84c7877..644688c5 100755 --- a/app/js/services.js +++ b/app/js/services.js @@ -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']) } 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']) 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']) return false; } } + if (update._ == 'updateChannelTooLong' && + !channelState.syncLoading) { + getChannelDifference(channelID); + } var popPts, popSeq;