feat: send message to user if file upload isn't completed and they try to close the tab
@@ -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) {
