Made post upload stop button abort current AJAX

This commit is contained in:
Marcin Kurczewski
2014-10-18 10:31:01 +02:00
parent 7e1b901a84
commit dd8050f250
2 changed files with 25 additions and 4 deletions

View File

@ -23,6 +23,7 @@ App.Presenters.PostUploadPresenter = function(
var fileDropper;
var interactionEnabled = true;
var currentUploadId = null;
var currentUploadXhr = null;
function init(params, loaded) {
topNavigationPresenter.select('upload');
@ -533,6 +534,9 @@ App.Presenters.PostUploadPresenter = function(
function stopUpload() {
currentUploadId = null;
showUploadError('Upload stopped.');
if (currentUploadXhr && currentUploadXhr.readystate !== api.AJAX_DONE) {
currentUploadXhr.abort();
}
}
function uploadNextPost() {
@ -566,7 +570,10 @@ App.Presenters.PostUploadPresenter = function(
return;
}
promise.wait(api.post('/posts', formData))
var apiPromise = api.post('/posts', formData);
currentUploadXhr = apiPromise.xhr;
promise.wait(apiPromise)
.then(function(response) {
$row.slideUp(function(response) {
if (priorUploadId === currentUploadId) {