Sequential file send

This commit is contained in:
Igor Zhukov 2014-04-08 13:51:29 +02:00
parent 376c1173ff
commit 9048fad53f

View File

@ -681,6 +681,7 @@ angular.module('myApp.services', [])
var pendingByRandomID = {};
var pendingByMessageID = {};
var pendingAfterMsgs = {};
var sendFilePromise = $q.when();
var tempID = -1;
@ -1214,6 +1215,9 @@ angular.module('myApp.services', [])
}
message.send = function () {
var sendFileDeferred = $q.defer();
sendFilePromise.then(function () {
var uploaded = false,
uploadPromise = MtpApiFileManager.uploadFile(file);
@ -1274,10 +1278,18 @@ angular.module('myApp.services', [])
media.progress.cancel = function () {
if (!uploaded) {
sendFileDeferred.resolve();
uploadPromise.cancel();
cancelPendingMessage(randomIDS);
}
}
uploadPromise['finally'](function () {
sendFileDeferred.resolve();
});
});
sendFilePromise = sendFileDeferred.promise;
};
saveMessages([message]);