diff --git a/app/js/lib/mtproto.js b/app/js/lib/mtproto.js index cc588b78..4b0b3357 100644 --- a/app/js/lib/mtproto.js +++ b/app/js/lib/mtproto.js @@ -151,7 +151,7 @@ angular.module('izhukov.mtproto', ['izhukov.utils']) lastMessageID = messageID; - // console.log('generated msg id', messageID); + // console.log('generated msg id', messageID, timeOffset); return longFromInts(messageID[0], messageID[1]); }; @@ -1321,10 +1321,6 @@ angular.module('izhukov.mtproto', ['izhukov.utils']) this.nextReq = nextReq; }; - MtpNetworker.prototype.onSessionCreate = function (sessionID, messageID) { - // console.log(dT(), 'New session created', bytesToHex(sessionID)); - }; - MtpNetworker.prototype.ackMessage = function (msgID) { // console.log('ack message', msgID); this.pendingAcks.push(msgID); @@ -1445,7 +1441,13 @@ angular.module('izhukov.mtproto', ['izhukov.utils']) this.processMessageAck(message.first_msg_id); this.applyServerSalt(message.server_salt); - this.onSessionCreate(sessionID, messageID); + + var self = this; + Storage.get('dc').then(function (baseDcID) { + if (baseDcID == self.dcID && !self.upload && updatesProcessor) { + updatesProcessor(message); + } + }); break; case 'msgs_ack': diff --git a/app/js/lib/utils.js b/app/js/lib/utils.js index 5b86429d..87a4b2c4 100644 --- a/app/js/lib/utils.js +++ b/app/js/lib/utils.js @@ -61,7 +61,7 @@ function onContentLoaded (cb) { }; function tsNow (seconds) { - var t = +new Date(); + var t = +new Date() + (window.tsOffset || 0); return seconds ? Math.floor(t / 1000) : t; } diff --git a/app/js/services.js b/app/js/services.js index 8a6b6602..1096a1aa 100644 --- a/app/js/services.js +++ b/app/js/services.js @@ -2936,6 +2936,7 @@ angular.module('myApp.services', ['myApp.i18n']) switch (updateMessage._) { case 'updatesTooLong': + case 'new_session_created': forceGetDifference(); break; @@ -3133,7 +3134,9 @@ angular.module('myApp.services', ['myApp.i18n']) curState.seq = stateResult.seq; curState.pts = stateResult.pts; curState.date = stateResult.date; - isSynchronizing = false; + setTimeout(function () { + isSynchronizing = false; + }, 1000); }) }