fix: ui set default max uploading to 1 (#220)
This commit is contained in:
parent
4622c48120
commit
8d7c1fbf53
1 changed files with 10 additions and 10 deletions
|
@ -22,6 +22,8 @@
|
||||||
* @property {string} editable
|
* @property {string} editable
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var DUFS_MAX_UPLOADINGS = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {DATA} DATA
|
* @type {DATA} DATA
|
||||||
*/
|
*/
|
||||||
|
@ -152,7 +154,6 @@ class Uploader {
|
||||||
}
|
}
|
||||||
|
|
||||||
ajax() {
|
ajax() {
|
||||||
Uploader.runnings += 1;
|
|
||||||
const url = newUrl(this.name);
|
const url = newUrl(this.name);
|
||||||
this.lastUptime = Date.now();
|
this.lastUptime = Date.now();
|
||||||
const ajax = new XMLHttpRequest();
|
const ajax = new XMLHttpRequest();
|
||||||
|
@ -187,13 +188,13 @@ class Uploader {
|
||||||
|
|
||||||
complete() {
|
complete() {
|
||||||
this.$uploadStatus.innerHTML = `✓`;
|
this.$uploadStatus.innerHTML = `✓`;
|
||||||
Uploader.runnings -= 1;
|
Uploader.runnings--;
|
||||||
Uploader.runQueue();
|
Uploader.runQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
fail() {
|
fail() {
|
||||||
this.$uploadStatus.innerHTML = `✗`;
|
this.$uploadStatus.innerHTML = `✗`;
|
||||||
Uploader.runnings -= 1;
|
Uploader.runnings--;
|
||||||
Uploader.runQueue();
|
Uploader.runQueue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -211,16 +212,14 @@ Uploader.queues = [];
|
||||||
|
|
||||||
|
|
||||||
Uploader.runQueue = async () => {
|
Uploader.runQueue = async () => {
|
||||||
if (Uploader.runnings > 2) return;
|
if (Uploader.runnings >= DUFS_MAX_UPLOADINGS) return;
|
||||||
|
if (Uploader.queues.length == 0) return;
|
||||||
|
Uploader.runnings++;
|
||||||
let uploader = Uploader.queues.shift();
|
let uploader = Uploader.queues.shift();
|
||||||
if (!uploader) return;
|
|
||||||
if (!Uploader.auth) {
|
if (!Uploader.auth) {
|
||||||
Uploader.auth = true;
|
Uploader.auth = true;
|
||||||
try {
|
const success = await login(true);
|
||||||
await login();
|
Uploader.auth = !!success;
|
||||||
} catch {
|
|
||||||
Uploader.auth = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
uploader.ajax();
|
uploader.ajax();
|
||||||
}
|
}
|
||||||
|
@ -662,6 +661,7 @@ async function login(alert = false) {
|
||||||
document.querySelector(".login-btn").classList.add("hidden");
|
document.querySelector(".login-btn").classList.add("hidden");
|
||||||
$userBtn.classList.remove("hidden");
|
$userBtn.classList.remove("hidden");
|
||||||
$userBtn.title = "";
|
$userBtn.title = "";
|
||||||
|
return true;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
let message = `Cannot login, ${err.message}`;
|
let message = `Cannot login, ${err.message}`;
|
||||||
if (alert) {
|
if (alert) {
|
||||||
|
|
Loading…
Reference in a new issue