|
|
@ -582,6 +582,10 @@ angular.module('izhukov.mtproto', ['izhukov.utils']) |
|
|
|
$rootScope.offline = true; |
|
|
|
$rootScope.offline = true; |
|
|
|
$rootScope.offlineConnecting = true; |
|
|
|
$rootScope.offlineConnecting = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Config.Navigator.mobile) { |
|
|
|
|
|
|
|
this.setupMobileSleep(); |
|
|
|
|
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
MtpNetworker.prototype.updateSession = function () { |
|
|
|
MtpNetworker.prototype.updateSession = function () { |
|
|
@ -596,6 +600,26 @@ angular.module('izhukov.mtproto', ['izhukov.utils']) |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MtpNetworker.prototype.setupMobileSleep = function () { |
|
|
|
|
|
|
|
var self = this; |
|
|
|
|
|
|
|
$rootScope.$watch('idle.isIDLE', function (isIDLE) { |
|
|
|
|
|
|
|
if (isIDLE) { |
|
|
|
|
|
|
|
self.sleepAfter = tsNow() + 30000; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
delete self.sleepAfter; |
|
|
|
|
|
|
|
self.checkLongPoll(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$rootScope.$on('push_received', function () { |
|
|
|
|
|
|
|
// console.log(dT(), 'push recieved', self.sleepAfter);
|
|
|
|
|
|
|
|
if (self.sleepAfter) { |
|
|
|
|
|
|
|
self.sleepAfter = tsNow() + 30000; |
|
|
|
|
|
|
|
self.checkLongPoll(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
MtpNetworker.prototype.updateSentMessage = function (sentMessageID) { |
|
|
|
MtpNetworker.prototype.updateSentMessage = function (sentMessageID) { |
|
|
|
var sentMessage = this.sentMessages[sentMessageID]; |
|
|
|
var sentMessage = this.sentMessages[sentMessageID]; |
|
|
|
if (!sentMessage) { |
|
|
|
if (!sentMessage) { |
|
|
@ -716,14 +740,18 @@ angular.module('izhukov.mtproto', ['izhukov.utils']) |
|
|
|
|
|
|
|
|
|
|
|
MtpNetworker.prototype.checkLongPoll = function(force) { |
|
|
|
MtpNetworker.prototype.checkLongPoll = function(force) { |
|
|
|
var isClean = this.cleanupSent(); |
|
|
|
var isClean = this.cleanupSent(); |
|
|
|
// console.log('Check lp', this.longPollPending, tsNow());
|
|
|
|
// console.log('Check lp', this.longPollPending, tsNow(), this.dcID, isClean);
|
|
|
|
if (this.longPollPending && tsNow() < this.longPollPending || this.offline) { |
|
|
|
if (this.longPollPending && tsNow() < this.longPollPending || this.offline) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
var self = this; |
|
|
|
var self = this; |
|
|
|
Storage.get('dc').then(function (baseDcID) { |
|
|
|
Storage.get('dc').then(function (baseDcID) { |
|
|
|
if (isClean && (baseDcID != self.dcID || self.upload)) { |
|
|
|
if (isClean && ( |
|
|
|
// console.warn('send long-poll for guest DC is delayed', self.dcID);
|
|
|
|
baseDcID != self.dcID || |
|
|
|
|
|
|
|
self.upload || |
|
|
|
|
|
|
|
self.sleepAfter && tsNow() > self.sleepAfter |
|
|
|
|
|
|
|
)) { |
|
|
|
|
|
|
|
// console.warn(dT(), 'Send long-poll for DC is delayed', self.dcID, self.sleepAfter);
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
self.sendLongPoll(); |
|
|
|
self.sendLongPoll(); |
|
|
|