mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-03-10 05:01:15 +01:00
Wait for answers on all conflicted files before uploading selected files
This commit is contained in:
parent
8b65f1286f
commit
6dae21b311
@ -119,6 +119,10 @@ export class Et2File extends Et2InputWidget(LitElement)
|
||||
protected resumable : Resumable = null;
|
||||
private __value : { [tempName : string] : FileInfo } = {};
|
||||
|
||||
// In case we need to do things between file added and start of upload, we wait
|
||||
protected _uploadPending : { [uniqueIdentifier : string] : Promise<void> } = {};
|
||||
private _uploadDelayTimeout : number;
|
||||
|
||||
/** Files already uploaded */
|
||||
@property({type: Object})
|
||||
set value(newValue : { [tempFileName : string] : FileInfo })
|
||||
@ -320,12 +324,30 @@ export class Et2File extends Et2InputWidget(LitElement)
|
||||
await fileItem.updateComplete;
|
||||
const ev = new CustomEvent("et2-add", {bubbles: true, detail: file})
|
||||
this.dispatchEvent(ev);
|
||||
setTimeout(this.resumable.upload, 100);
|
||||
|
||||
if(typeof this.onStart == "function")
|
||||
{
|
||||
this.onStart(ev);
|
||||
}
|
||||
if(ev.defaultPrevented)
|
||||
{
|
||||
// Event handling canceled the upload
|
||||
file.cancel();
|
||||
}
|
||||
// We can't pause individual files, just the upload as a whole, so wait together
|
||||
if(this._uploadDelayTimeout)
|
||||
{
|
||||
window.clearTimeout(this._uploadDelayTimeout);
|
||||
}
|
||||
this._uploadDelayTimeout = window.setTimeout(() =>
|
||||
{
|
||||
Promise.allSettled(Object.values(this._uploadPending)).then(() =>
|
||||
{
|
||||
this._uploadPending = {};
|
||||
this._uploadDelayTimeout = null;
|
||||
setTimeout(this.resumable.upload);
|
||||
});
|
||||
}, 100);
|
||||
}
|
||||
|
||||
protected resumableFileProgress(file : FileInfo, event)
|
||||
|
@ -113,7 +113,11 @@ export class Et2VfsUpload extends Et2File
|
||||
{
|
||||
return superAdded(info, event);
|
||||
}
|
||||
this.egw().request("EGroupware\\Api\\Etemplate\\Widget\\Vfs::ajax_conflict_check", [
|
||||
// Pause uploads while we check
|
||||
this.resumable.pause();
|
||||
|
||||
this._uploadPending[info.uniqueIdentifier] = this.egw().request(
|
||||
"EGroupware\\Api\\Etemplate\\Widget\\Vfs::ajax_conflict_check", [
|
||||
this.getInstanceManager()?.etemplate_exec_id, // request_id
|
||||
this.path, // path
|
||||
info.file.name,
|
||||
@ -190,7 +194,7 @@ export class Et2VfsUpload extends Et2File
|
||||
// Upload as set
|
||||
return true;
|
||||
case "rename":
|
||||
info.fileName = value?.value ?? info.fileName;
|
||||
info.fileName = info['name'] = value?.value ?? info.fileName;
|
||||
return true;
|
||||
case "cancel":
|
||||
// Don't upload
|
||||
|
Loading…
Reference in New Issue
Block a user