diff --git a/src/api/files.js b/src/api/files.js index 971b056e..00d16339 100644 --- a/src/api/files.js +++ b/src/api/files.js @@ -94,6 +94,9 @@ export async function post (url, content = '', overwrite = false, onupload) { request.upload.onprogress = onupload } + // Send a message to user before closing the tab during file upload + window.onbeforeunload = () => "Files are being uploaded." + request.onload = () => { if (request.status === 200) { resolve(request.responseText) @@ -109,7 +112,8 @@ export async function post (url, content = '', overwrite = false, onupload) { } request.send(content) - }) + // Upload is done no more message before closing the tab + }).finally(() => { window.onbeforeunload = null }) } function moveCopy (items, copy = false) {