I forgot how timeout works. it should work now

This commit is contained in:
2018-01-17 11:13:15 +01:00
parent 4957ef5552
commit 54f18cacf5
2 changed files with 10 additions and 10 deletions

View File

@@ -110,13 +110,13 @@ var UploadManager = /** @class */ (function () {
this.uploadQueue.push(file);
if (this.uploadThreads.length < this.maxThreads) {
console.debug("Starting upload thread");
var thread = new UploadWorker(this);
this.uploadThreads.push(thread);
setTimeout(thread.start(), 0); // Start a new upload thread
var thread_1 = new UploadWorker(this);
this.uploadThreads.push(thread_1);
setTimeout(function () { thread_1.start(); }, 0); // Start a new upload thread
}
else {
for (var i = 0; i < this.uploadThreads.length; i++) {
setTimeout(this.uploadThreads[i].start(), 0);
setTimeout(function () { this.uploadThreads[i].start(); }, 0);
}
}
};
@@ -186,12 +186,12 @@ var UploadWorker = /** @class */ (function () {
if (that.tries === 3) {
alert("Upload failed: " + status);
file.onFailure(status, error);
setTimeout(that.newFile(), 2000); // Try to continue
setTimeout(function () { that.newFile(); }, 2000); // Try to continue
return; // Upload failed
}
// Try again
that.tries++;
setTimeout(that.upload(file), that.tries * 3000);
setTimeout(function () { that.upload(file); }, that.tries * 3000);
}
});
};

View File

@@ -18,10 +18,10 @@ class UploadManager {
console.debug("Starting upload thread")
let thread = new UploadWorker(this)
this.uploadThreads.push(thread)
setTimeout(thread.start(), 0) // Start a new upload thread
setTimeout(function(){thread.start()}, 0) // Start a new upload thread
} else {
for (var i = 0; i < this.uploadThreads.length; i++) {
setTimeout(this.uploadThreads[i].start(), 0)
setTimeout(function(){this.uploadThreads[i].start()}, 0)
}
}
}
@@ -101,13 +101,13 @@ class UploadWorker {
alert("Upload failed: " + status);
file.onFailure(status, error)
setTimeout(that.newFile(), 2000) // Try to continue
setTimeout(function(){that.newFile()}, 2000) // Try to continue
return; // Upload failed
}
// Try again
that.tries++
setTimeout(that.upload(file), that.tries*3000)
setTimeout(function(){that.upload(file)}, that.tries*3000)
}
});
}