Browse Source

Performance improvements by disabling workers, adding http_wait to all api requests

master
Igor Zhukov 11 years ago
parent
commit
72b7beaa31
  1. 19
      app/css/app.css
  2. 1
      app/js/controllers.js
  3. 114
      app/js/lib/mtproto.js
  4. 4
      app/vendor/ui-bootstrap/ui-bootstrap-custom-tpls-0.10.0.js

19
app/css/app.css

@ -276,10 +276,10 @@ input[type="number"]::-webkit-inner-spin-button {
border-radius: 3px; border-radius: 3px;
} }
.tg_progress .progress-bar { .tg_progress .progress-bar {
height: 2px; height: 5px;
line-height: 2px; line-height: 2px;
background: rgba(255,255,255, 0.9); background: rgba(255,255,255, 0.9);
border-radius: 2px; border-radius: 0;
overflow: hidden; overflow: hidden;
} }
@ -402,10 +402,16 @@ input[type="number"]::-webkit-inner-spin-button {
} }
.img_fullsize_progress { .img_fullsize_progress {
position: absolute; position: absolute;
bottom: 15px; bottom: 0;
left: 50%; left: 0;
width: 190px; width: 100%;
margin-left: -95px; height: 25px;
margin: 0;
padding: 0;
background: rgba(0,0,0, 0.5);
border: 0;
border-radius: 0;
padding: 10px;
} }
@ -2390,6 +2396,7 @@ a.contacts_modal_contact:hover .contacts_modal_contact_status {
width: 112px; width: 112px;
height: 52px; height: 52px;
margin: -8px 0 0 -112px; margin: -8px 0 0 -112px;
-webkit-user-select: text;
} }
@media (min-width: 1024px) { @media (min-width: 1024px) {
.im_content_message_select_area { .im_content_message_select_area {

1
app/js/controllers.js

@ -458,6 +458,7 @@ angular.module('myApp.controllers', [])
if (prevMessage && if (prevMessage &&
curMessage.from_id == prevMessage.from_id && curMessage.from_id == prevMessage.from_id &&
curMessage.date < prevMessage.date + 30 && curMessage.date < prevMessage.date + 30 &&
!curMessage.fwd_from_id &&
curMessage.message && curMessage.message.length < 30) { curMessage.message && curMessage.message.length < 30) {
curMessage.grouped = true; curMessage.grouped = true;
} else if (!start) { } else if (!start) {

114
app/js/lib/mtproto.js

@ -1101,7 +1101,7 @@ factory('MtpAuthorizer', function (MtpDcConfigurator, MtpRsaKeysManager, MtpSecu
request.storeMethod('req_pq', {nonce: auth.nonce}); request.storeMethod('req_pq', {nonce: auth.nonce});
console.log('Send req_pq', bytesToHex(auth.nonce)); console.log(dT(), 'Send req_pq', bytesToHex(auth.nonce));
mtpSendPlainRequest(auth.dcID, request.getBuffer()).then(function (result) { mtpSendPlainRequest(auth.dcID, request.getBuffer()).then(function (result) {
var deserializer = result.data; var deserializer = result.data;
var response = deserializer.fetchObject('ResPQ'); var response = deserializer.fetchObject('ResPQ');
@ -1118,7 +1118,7 @@ factory('MtpAuthorizer', function (MtpDcConfigurator, MtpRsaKeysManager, MtpSecu
auth.pq = response.pq; auth.pq = response.pq;
auth.fingerprints = response.server_public_key_fingerprints; auth.fingerprints = response.server_public_key_fingerprints;
console.log('Got ResPQ', bytesToHex(auth.serverNonce), bytesToHex(auth.pq), auth.fingerprints); console.log(dT(), 'Got ResPQ', bytesToHex(auth.serverNonce), bytesToHex(auth.pq), auth.fingerprints);
auth.publicKey = MtpRsaKeysManager.select(auth.fingerprints); auth.publicKey = MtpRsaKeysManager.select(auth.fingerprints);
@ -1126,8 +1126,8 @@ factory('MtpAuthorizer', function (MtpDcConfigurator, MtpRsaKeysManager, MtpSecu
throw new Error('No public key found'); throw new Error('No public key found');
} }
console.log('PQ factorization start'); console.log(dT(), 'PQ factorization start');
if (!!window.Worker) { if (!!window.Worker && false) {
var worker = new Worker('js/lib/pq_worker.js'); var worker = new Worker('js/lib/pq_worker.js');
worker.onmessage = function (e) { worker.onmessage = function (e) {
@ -1185,7 +1185,7 @@ factory('MtpAuthorizer', function (MtpDcConfigurator, MtpRsaKeysManager, MtpSecu
encrypted_data: rsaEncrypt(auth.publicKey, dataWithHash) encrypted_data: rsaEncrypt(auth.publicKey, dataWithHash)
}); });
console.log('Send req_DH_params'); console.log(dT(), 'Send req_DH_params');
mtpSendPlainRequest(auth.dcID, request.getBuffer()).then(function (result) { mtpSendPlainRequest(auth.dcID, request.getBuffer()).then(function (result) {
var deserializer = result.data; var deserializer = result.data;
var response = deserializer.fetchObject('Server_DH_Params', 'RESPONSE'); var response = deserializer.fetchObject('Server_DH_Params', 'RESPONSE');
@ -1255,7 +1255,7 @@ factory('MtpAuthorizer', function (MtpDcConfigurator, MtpRsaKeysManager, MtpSecu
throw new Error('server_DH_inner_data serverNonce mismatch'); throw new Error('server_DH_inner_data serverNonce mismatch');
} }
console.log('Done decrypting answer'); console.log(dT(), 'Done decrypting answer');
auth.g = response.g; auth.g = response.g;
auth.dhPrime = response.dh_prime; auth.dhPrime = response.dh_prime;
auth.gA = response.g_a; auth.gA = response.g_a;
@ -1302,7 +1302,7 @@ factory('MtpAuthorizer', function (MtpDcConfigurator, MtpRsaKeysManager, MtpSecu
encrypted_data: encryptedData encrypted_data: encryptedData
}); });
console.log('Send set_client_DH_params'); console.log(dT(), 'Send set_client_DH_params');
mtpSendPlainRequest(auth.dcID, request.getBuffer()).then(function (result) { mtpSendPlainRequest(auth.dcID, request.getBuffer()).then(function (result) {
var deserializer = result.data; var deserializer = result.data;
var response = deserializer.fetchObject('Set_client_DH_params_answer'); var response = deserializer.fetchObject('Set_client_DH_params_answer');
@ -1330,7 +1330,7 @@ factory('MtpAuthorizer', function (MtpDcConfigurator, MtpRsaKeysManager, MtpSecu
authKeyAux = authKeyHash.slice(0, 8), authKeyAux = authKeyHash.slice(0, 8),
authKeyID = authKeyHash.slice(-8); authKeyID = authKeyHash.slice(-8);
console.log('Got Set_client_DH_params_answer', response._); console.log(dT(), 'Got Set_client_DH_params_answer', response._);
switch (response._) { switch (response._) {
case 'dh_gen_ok': case 'dh_gen_ok':
var newNonceHash1 = sha1Hash(auth.newNonce.concat([1], authKeyAux)).slice(-16); var newNonceHash1 = sha1Hash(auth.newNonce.concat([1], authKeyAux)).slice(-16);
@ -1411,7 +1411,7 @@ factory('MtpAuthorizer', function (MtpDcConfigurator, MtpRsaKeysManager, MtpSecu
}). }).
factory('MtpAesService', function ($q) { factory('MtpAesService', function ($q) {
if (!window.Worker/* || true*/) { if (!window.Worker || true) {
return { return {
encrypt: function (bytes, keyBytes, ivBytes) { encrypt: function (bytes, keyBytes, ivBytes) {
return $q.when(aesEncrypt(bytes, keyBytes, ivBytes)); return $q.when(aesEncrypt(bytes, keyBytes, ivBytes));
@ -1466,10 +1466,16 @@ factory('MtpAesService', function ($q) {
factory('MtpSha1Service', function ($q) { factory('MtpSha1Service', function ($q) {
if (!window.Worker/* || true*/) { if (!window.Worker || true) {
return { return {
hash: function (bytes) { hash: function (bytes) {
return $q.when(sha1Hash(bytes)); var deferred = $q.defer();
setTimeout(function () {
deferred.resolve(sha1Hash(bytes));
}, 0);
return deferred.promise;
} }
}; };
} }
@ -1556,7 +1562,7 @@ factory('MtpNetworkerFactory', function (MtpDcConfigurator, MtpMessageIdGenerato
}; };
MtpNetworker.prototype.updateSession = function () { MtpNetworker.prototype.updateSession = function () {
console.log('Update session'); console.log(dT(), 'Update session');
this.seqNo = 0; this.seqNo = 0;
this.sessionID = new Array(8); this.sessionID = new Array(8);
MtpSecureRandom.nextBytes(this.sessionID); MtpSecureRandom.nextBytes(this.sessionID);
@ -1620,7 +1626,7 @@ factory('MtpNetworkerFactory', function (MtpDcConfigurator, MtpMessageIdGenerato
}; };
if (window._debugMode) { if (window._debugMode) {
console.log('MT call', method, params, messageID, seqNo); console.log(dT(), 'MT call', method, params, messageID, seqNo);
} }
return this.pushMessage(message, options); return this.pushMessage(message, options);
@ -1641,7 +1647,7 @@ factory('MtpNetworkerFactory', function (MtpDcConfigurator, MtpMessageIdGenerato
}; };
if (window._debugMode) { if (window._debugMode) {
console.log('MT message', object, messageID, seqNo); console.log(dT(), 'MT message', object, messageID, seqNo);
} }
return this.pushMessage(message, options); return this.pushMessage(message, options);
@ -1677,9 +1683,9 @@ factory('MtpNetworkerFactory', function (MtpDcConfigurator, MtpMessageIdGenerato
}; };
if (window._debugMode) { if (window._debugMode) {
console.log('Api call', method, params, messageID, seqNo, options); console.log(dT(), 'Api call', method, params, messageID, seqNo, options);
} else { } else {
console.log('Api call', method, messageID, seqNo); console.log(dT(), 'Api call', method, messageID, seqNo);
} }
return this.pushMessage(message, options); return this.pushMessage(message, options);
@ -1713,7 +1719,8 @@ factory('MtpNetworkerFactory', function (MtpDcConfigurator, MtpMessageIdGenerato
wait_after: 0, wait_after: 0,
max_wait: maxWait max_wait: maxWait
}, { }, {
noResponse: true noResponse: true,
longPoll: true
}).then(function () { }).then(function () {
delete self.longPollPending; delete self.longPollPending;
$timeout(self.checkLongPoll.bind(self), 0); $timeout(self.checkLongPoll.bind(self), 0);
@ -1777,7 +1784,7 @@ factory('MtpNetworkerFactory', function (MtpDcConfigurator, MtpMessageIdGenerato
MtpNetworker.prototype.checkConnection = function(event) { MtpNetworker.prototype.checkConnection = function(event) {
$rootScope.offlineConnecting = true; $rootScope.offlineConnecting = true;
console.log('check connection', event); console.log(dT(), 'Check connection', event);
$timeout.cancel(this.checkConnectionPromise); $timeout.cancel(this.checkConnectionPromise);
var serializer = new TLSerialization({mtproto: true}), var serializer = new TLSerialization({mtproto: true}),
@ -1796,7 +1803,7 @@ factory('MtpNetworkerFactory', function (MtpDcConfigurator, MtpMessageIdGenerato
delete $rootScope.offlineConnecting; delete $rootScope.offlineConnecting;
self.toggleOffline(false); self.toggleOffline(false);
}, function () { }, function () {
console.log('delay ', self.checkConnectionPeriod * 1000); console.log(dT(), 'Delay ', self.checkConnectionPeriod * 1000);
self.checkConnectionPromise = $timeout(self.checkConnection.bind(self), parseInt(self.checkConnectionPeriod * 1000)); self.checkConnectionPromise = $timeout(self.checkConnection.bind(self), parseInt(self.checkConnectionPeriod * 1000));
self.checkConnectionPeriod = Math.min(60, self.checkConnectionPeriod * 1.5); self.checkConnectionPeriod = Math.min(60, self.checkConnectionPeriod * 1.5);
$timeout(function () { $timeout(function () {
@ -1847,7 +1854,7 @@ factory('MtpNetworkerFactory', function (MtpDcConfigurator, MtpMessageIdGenerato
MtpNetworker.prototype.performSheduledRequest = function() { MtpNetworker.prototype.performSheduledRequest = function() {
// console.trace('sheduled', this.dcID, this.iii); // console.trace('sheduled', this.dcID, this.iii);
if (this.offline) { if (this.offline) {
console.log('cancel sheduled'); console.log(dT(), 'Cancel sheduled');
return false; return false;
} }
delete this.nextReq; delete this.nextReq;
@ -1873,6 +1880,8 @@ factory('MtpNetworkerFactory', function (MtpDcConfigurator, MtpMessageIdGenerato
message, message,
messagesByteLen = 0, messagesByteLen = 0,
currentTime = tsNow(), currentTime = tsNow(),
hasApiCall = false,
hasHttpWait = false,
self = this; self = this;
angular.forEach(this.pendingMessages, function (value, messageID) { angular.forEach(this.pendingMessages, function (value, messageID) {
@ -1880,6 +1889,12 @@ factory('MtpNetworkerFactory', function (MtpDcConfigurator, MtpMessageIdGenerato
if (message = self.sentMessages[messageID]) { if (message = self.sentMessages[messageID]) {
messages.push(message); messages.push(message);
messagesByteLen += message.body.length + 32; messagesByteLen += message.body.length + 32;
if (message.isAPI) {
hasApiCall = true;
}
else if (message.longPoll) {
hasHttpWait = true;
}
} else { } else {
// console.log(message, messageID); // console.log(message, messageID);
} }
@ -1887,6 +1902,16 @@ factory('MtpNetworkerFactory', function (MtpDcConfigurator, MtpMessageIdGenerato
} }
}); });
if (hasApiCall && !hasHttpWait) {
var serializer = new TLSerialization({mtproto: true});
serializer.storeMethod('http_wait', {max_delay: 0, wait_after: 0, max_wait: 25000});
messages.push({
msg_id: MtpMessageIdGenerator.generateID(),
seq_no: this.generateSeqNo(),
body: serializer.getBytes()
});
}
if (!messages.length) { if (!messages.length) {
// console.log('no sheduled messages'); // console.log('no sheduled messages');
return; return;
@ -1923,7 +1948,7 @@ factory('MtpNetworkerFactory', function (MtpDcConfigurator, MtpMessageIdGenerato
this.sentMessages[message.msg_id] = containerSentMessage; this.sentMessages[message.msg_id] = containerSentMessage;
if (window._debugMode) { if (window._debugMode) {
console.log('Container', innerMessages, message.msg_id, message.seq_no); console.log(dT(), 'Container', innerMessages, message.msg_id, message.seq_no);
} }
} else { } else {
if (message.noResponse) { if (message.noResponse) {
@ -1939,7 +1964,7 @@ factory('MtpNetworkerFactory', function (MtpDcConfigurator, MtpMessageIdGenerato
self.toggleOffline(false); self.toggleOffline(false);
self.parseResponse(result.data).then(function (response) { self.parseResponse(result.data).then(function (response) {
if (window._debugMode) { if (window._debugMode) {
console.log('Server response', self.dcID, response); console.log(dT(), 'Server response', self.dcID, response);
} }
self.processMessage(response.response, response.messageID, response.sessionID); self.processMessage(response.response, response.messageID, response.sessionID);
@ -1992,8 +2017,10 @@ factory('MtpNetworkerFactory', function (MtpDcConfigurator, MtpMessageIdGenerato
var msgKey = bytesHash.slice(-16); var msgKey = bytesHash.slice(-16);
return self.getMsgKeyIv(msgKey, true).then(function (keyIv) { return self.getMsgKeyIv(msgKey, true).then(function (keyIv) {
// console.log('keyIv', keyIv); // console.log('keyIv', keyIv);
// console.time('Aes encrypt ' + bytes.length + ' bytes');
return MtpAesService.encrypt(bytes, keyIv[0], keyIv[1]).then(function (encryptedBytes) { return MtpAesService.encrypt(bytes, keyIv[0], keyIv[1]).then(function (encryptedBytes) {
// console.log('encryptedBytes', encryptedBytes); // console.log('encryptedBytes', encryptedBytes);
// console.timeEnd('Aes encrypt ' + bytes.length + ' bytes');
return { return {
bytes: encryptedBytes, bytes: encryptedBytes,
msgKey: msgKey msgKey: msgKey
@ -2005,13 +2032,17 @@ factory('MtpNetworkerFactory', function (MtpDcConfigurator, MtpMessageIdGenerato
MtpNetworker.prototype.getDecryptedMessage = function (msgKey, encryptedData) { MtpNetworker.prototype.getDecryptedMessage = function (msgKey, encryptedData) {
return this.getMsgKeyIv(msgKey, false).then(function (keyIv) { return this.getMsgKeyIv(msgKey, false).then(function (keyIv) {
return MtpAesService.decrypt(encryptedData, keyIv[0], keyIv[1]); // console.time('Aes decrypt ' + encryptedData.length + ' bytes');
return MtpAesService.decrypt(encryptedData, keyIv[0], keyIv[1])/*.then(function (a) {
console.timeEnd('Aes decrypt ' + encryptedData.length + ' bytes');
return a;
})*/;
}); });
}; };
MtpNetworker.prototype.sendEncryptedRequest = function (message) { MtpNetworker.prototype.sendEncryptedRequest = function (message) {
var self = this; var self = this;
// console.log('send encrypted', message); // console.log(dT(), 'Send encrypted'/*, message*/);
// console.trace(); // console.trace();
var data = new TLSerialization({startMaxLength: message.body.length + 64}); var data = new TLSerialization({startMaxLength: message.body.length + 64});
@ -2025,7 +2056,7 @@ factory('MtpNetworkerFactory', function (MtpDcConfigurator, MtpMessageIdGenerato
data.storeRawBytes(message.body, 'message_data'); data.storeRawBytes(message.body, 'message_data');
return this.getEncryptedMessage(data.getBytes()).then(function (encryptedResult) { return this.getEncryptedMessage(data.getBytes()).then(function (encryptedResult) {
// console.log('got enc result', encryptedResult); // console.log(dT(), 'Got encrypted out message'/*, encryptedResult*/);
var request = new TLSerialization({startMaxLength: encryptedResult.bytes.length + 256}); var request = new TLSerialization({startMaxLength: encryptedResult.bytes.length + 256});
request.storeIntBytes(self.authKeyID, 64, 'auth_key_id'); request.storeIntBytes(self.authKeyID, 64, 'auth_key_id');
request.storeIntBytes(encryptedResult.msgKey, 128, 'msg_key'); request.storeIntBytes(encryptedResult.msgKey, 128, 'msg_key');
@ -2047,6 +2078,7 @@ factory('MtpNetworkerFactory', function (MtpDcConfigurator, MtpMessageIdGenerato
}; };
MtpNetworker.prototype.parseResponse = function (responseBuffer) { MtpNetworker.prototype.parseResponse = function (responseBuffer) {
// console.log(dT(), 'Start parsing response');
var self = this; var self = this;
var deserializer = new TLDeserialization(responseBuffer); var deserializer = new TLDeserialization(responseBuffer);
@ -2126,7 +2158,7 @@ factory('MtpNetworkerFactory', function (MtpDcConfigurator, MtpMessageIdGenerato
}; };
MtpNetworker.prototype.onSessionCreate = function (sessionID, messageID) { MtpNetworker.prototype.onSessionCreate = function (sessionID, messageID) {
console.log('New session created', bytesToHex(sessionID)); console.log(dT(), 'New session created', bytesToHex(sessionID));
}; };
MtpNetworker.prototype.ackMessage = function (msgID) { MtpNetworker.prototype.ackMessage = function (msgID) {
@ -2136,7 +2168,7 @@ factory('MtpNetworkerFactory', function (MtpDcConfigurator, MtpMessageIdGenerato
}; };
MtpNetworker.prototype.reqResendMessage = function (msgID) { MtpNetworker.prototype.reqResendMessage = function (msgID) {
console.log('req resend', msgID); console.log(dT(), 'Req resend', msgID);
this.pendingResends.push(msgID); this.pendingResends.push(msgID);
this.sheduleRequest(100); this.sheduleRequest(100);
}; };
@ -2206,7 +2238,7 @@ factory('MtpNetworkerFactory', function (MtpDcConfigurator, MtpMessageIdGenerato
break; break;
case 'bad_server_salt': case 'bad_server_salt':
console.log('Bad server salt', message); console.log(dT(), 'Bad server salt', message);
var sentMessage = this.sentMessages[message.bad_msg_id]; var sentMessage = this.sentMessages[message.bad_msg_id];
if (!sentMessage || sentMessage.seq_no != message.bad_msg_seqno) { if (!sentMessage || sentMessage.seq_no != message.bad_msg_seqno) {
console.log(message.bad_msg_id, message.bad_msg_seqno); console.log(message.bad_msg_id, message.bad_msg_seqno);
@ -2219,7 +2251,7 @@ factory('MtpNetworkerFactory', function (MtpDcConfigurator, MtpMessageIdGenerato
break; break;
case 'bad_msg_notification': case 'bad_msg_notification':
console.log('Bad msg notification', message); console.log(dT(), 'Bad msg notification', message);
var sentMessage = this.sentMessages[message.bad_msg_id]; var sentMessage = this.sentMessages[message.bad_msg_id];
if (!sentMessage || sentMessage.seq_no != message.bad_msg_seqno) { if (!sentMessage || sentMessage.seq_no != message.bad_msg_seqno) {
console.log(message.bad_msg_id, message.bad_msg_seqno); console.log(message.bad_msg_id, message.bad_msg_seqno);
@ -2278,16 +2310,16 @@ factory('MtpNetworkerFactory', function (MtpDcConfigurator, MtpMessageIdGenerato
var deferred = sentMessage.deferred; var deferred = sentMessage.deferred;
if (message.result._ == 'rpc_error') { if (message.result._ == 'rpc_error') {
var error = this.processError(message.result); var error = this.processError(message.result);
console.log('rpc error', error) console.log(dT(), 'Rpc error', error)
if (deferred) { if (deferred) {
deferred.reject(error) deferred.reject(error)
} }
} else { } else {
if (deferred) { if (deferred) {
if (window._debugMode) { if (window._debugMode) {
console.log('rpc response', message.result); console.log(dT(), 'Rpc response', message.result);
} else { } else {
console.log('rpc response', message.result._); console.log(dT(), 'Rpc response', message.result._);
} }
sentMessage.deferred.resolve(message.result); sentMessage.deferred.resolve(message.result);
} }
@ -2435,7 +2467,7 @@ factory('MtpApiManager', function (AppConfigManager, MtpAuthorizer, MtpNetworker
// }, 1000); // }, 1000);
}, },
function (error) { function (error) {
console.log('error', error.code, error.type, baseDcID, dcID); console.error(dT(), 'Error', error.code, error.type, baseDcID, dcID);
if (error.code == 401 && baseDcID && dcID != baseDcID) { if (error.code == 401 && baseDcID && dcID != baseDcID) {
if (cachedExportPromise[dcID] === undefined) { if (cachedExportPromise[dcID] === undefined) {
var exportDeferred = $q.defer(); var exportDeferred = $q.defer();
@ -2756,7 +2788,7 @@ factory('MtpApiFileManager', function (MtpApiManager, $q, $window) {
function downloadFile (dcID, location, size, fileEntry, options) { function downloadFile (dcID, location, size, fileEntry, options) {
options = options || {}; options = options || {};
console.log('dload file', dcID, location, size); console.log(dT(), 'Dload file', dcID, location, size);
var fileName = getFileName(location), var fileName = getFileName(location),
cachedPromise = cachedSavePromises[fileName] || cachedDownloadPromises[fileName]; cachedPromise = cachedSavePromises[fileName] || cachedDownloadPromises[fileName];
@ -2776,10 +2808,11 @@ factory('MtpApiFileManager', function (MtpApiManager, $q, $window) {
saveToFileEntry = function (fileEntry) { saveToFileEntry = function (fileEntry) {
fileEntry.createWriter(function (fileWriter) { fileEntry.createWriter(function (fileWriter) {
cacheFileWriter = fileWriter; cacheFileWriter = fileWriter;
// console.time(fileName + ' ' + (size / 1024));
// var limit = size > 102400 ? 65536 : 4096; // var limit = size > 102400 ? 65536 : 4096;
var limit = size > 30400 ? 524288 : 4096; var limit = size > 30400 ? 524288 : 4096;
// var limit = size > 30400 ? 20480 : 4096; // var limit = size > 30400 ? 50480 : 4096;
var writeFilePromise = $q.when(), var writeFilePromise = $q.when(),
writeFileDeferred; writeFileDeferred;
for (var offset = 0; offset < size; offset += limit) { for (var offset = 0; offset < size; offset += limit) {
@ -2811,6 +2844,7 @@ factory('MtpApiFileManager', function (MtpApiManager, $q, $window) {
}, errorHandler).then(function () { }, errorHandler).then(function () {
if (isFinal) { if (isFinal) {
// console.timeEnd(fileName + ' ' + (size / 1024));
deferred.resolve(cachedDownloads[fileName] = fileEntry.toURL(options.mime || 'image/jpeg')); deferred.resolve(cachedDownloads[fileName] = fileEntry.toURL(options.mime || 'image/jpeg'));
} else { } else {
// console.log('notify', {done: offset + limit, total: size}); // console.log('notify', {done: offset + limit, total: size});
@ -2838,8 +2872,8 @@ factory('MtpApiFileManager', function (MtpApiManager, $q, $window) {
requestFS().then(function () { requestFS().then(function () {
cachedFS.root.getFile(fileName, {create: false}, function(fileEntry) { cachedFS.root.getFile(fileName, {create: false}, function(fileEntry) {
fileEntry.file(function(file) { fileEntry.file(function(file) {
console.log('check size', file.size, size); // console.log(dT(), 'Check size', file.size, size);
if (file.size >= size) { if (file.size >= size/* && false*/) {
deferred.resolve(cachedDownloads[fileName] = fileEntry.toURL()); deferred.resolve(cachedDownloads[fileName] = fileEntry.toURL());
} else { } else {
console.log('File bad size', file, size); console.log('File bad size', file, size);
@ -2912,7 +2946,7 @@ factory('MtpApiFileManager', function (MtpApiManager, $q, $window) {
} }
function writeFile (file) { function writeFile (file) {
console.log('write file', file); console.log(dT(), 'Write file', file);
var fileName = getTempFileName(file); var fileName = getTempFileName(file);
var deferred = $q.defer(), var deferred = $q.defer(),
@ -2954,7 +2988,7 @@ factory('MtpApiFileManager', function (MtpApiManager, $q, $window) {
var fileID = [nextRandomInt(0xFFFFFFFF), nextRandomInt(0xFFFFFFFF)], var fileID = [nextRandomInt(0xFFFFFFFF), nextRandomInt(0xFFFFFFFF)],
deferred = $q.defer(), deferred = $q.defer(),
errorHandler = function (error) { errorHandler = function (error) {
console.log('error', error); console.error('Error', error);
deferred.reject(error); deferred.reject(error);
errorHandler = angular.noop; errorHandler = angular.noop;
}, },
@ -3000,7 +3034,7 @@ factory('MtpApiFileManager', function (MtpApiManager, $q, $window) {
if (doneParts >= totalParts) { if (doneParts >= totalParts) {
deferred.resolve(resultInputFile); deferred.resolve(resultInputFile);
} else { } else {
console.log('Progress', doneParts * partSize / fileSize); console.log(dT(), 'Progress', doneParts * partSize / fileSize);
deferred.notify({done: doneParts * partSize, total: fileSize}); deferred.notify({done: doneParts * partSize, total: fileSize});
} }
}, errorHandler); }, errorHandler);

4
app/vendor/ui-bootstrap/ui-bootstrap-custom-tpls-0.10.0.js vendored

@ -362,7 +362,7 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.transition'])
openedWindows.remove(modalInstance); openedWindows.remove(modalInstance);
//remove window DOM element //remove window DOM element
removeAfterAnimate(modalWindow.modalDomEl, modalWindow.modalScope, 300, checkRemoveBackdrop); removeAfterAnimate(modalWindow.modalDomEl, modalWindow.modalScope, 0, checkRemoveBackdrop);
body.toggleClass(OPENED_MODAL_CLASS, openedWindows.length() > 0); body.toggleClass(OPENED_MODAL_CLASS, openedWindows.length() > 0);
} }
@ -370,7 +370,7 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.transition'])
//remove backdrop if no longer needed //remove backdrop if no longer needed
if (backdropDomEl && backdropIndex() == -1) { if (backdropDomEl && backdropIndex() == -1) {
var backdropScopeRef = backdropScope; var backdropScopeRef = backdropScope;
removeAfterAnimate(backdropDomEl, backdropScope, 150, function () { removeAfterAnimate(backdropDomEl, backdropScope, 0, function () {
backdropScopeRef.$destroy(); backdropScopeRef.$destroy();
backdropScopeRef = null; backdropScopeRef = null;
}); });

Loading…
Cancel
Save