feat: send message to user if file upload isn't completed and they try to close the tab

pull/739/head
Alexandre Stein 2019-01-26 12:27:58 +01:00 committed by Henrique Dias
parent ba5b5fbfe3
commit d004015f03
1 changed files with 5 additions and 1 deletions

View File

@ -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) {