Merge pull request #496 from qligier/pr-fix-upload
Fix upload duplicates
This commit is contained in:
commit
c2b66db01f
BIN
dist/main.js
vendored
BIN
dist/main.js
vendored
Binary file not shown.
BIN
dist/view.js
vendored
BIN
dist/view.js
vendored
Binary file not shown.
@ -187,12 +187,7 @@ build.uploadModal = function(title, files) {
|
|||||||
html += lychee.html`
|
html += lychee.html`
|
||||||
<div class='row'>
|
<div class='row'>
|
||||||
<a class='name'>$${ file.name }</a>
|
<a class='name'>$${ file.name }</a>
|
||||||
`
|
<a class='status'></a>
|
||||||
|
|
||||||
if (file.supported===true) html += `<a class='status'></a>`
|
|
||||||
else html += `<a class='status error'>Not supported</a>`
|
|
||||||
|
|
||||||
html += `
|
|
||||||
<p class='notice'></p>
|
<p class='notice'></p>
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
|
@ -46,10 +46,11 @@ upload.start = {
|
|||||||
|
|
||||||
const process = function(files, file) {
|
const process = function(files, file) {
|
||||||
|
|
||||||
let formData = new FormData()
|
let formData = new FormData()
|
||||||
let xhr = new XMLHttpRequest()
|
let xhr = new XMLHttpRequest()
|
||||||
let pre_progress = 0
|
let pre_progress = 0
|
||||||
let progress = 0
|
let progress = 0
|
||||||
|
let next_file_started = false
|
||||||
|
|
||||||
const finish = function() {
|
const finish = function() {
|
||||||
|
|
||||||
@ -84,34 +85,6 @@ upload.start = {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if file is supported
|
|
||||||
if (file.supported===false) {
|
|
||||||
|
|
||||||
// Skip file
|
|
||||||
if (file.next!=null) process(files, file.next)
|
|
||||||
else {
|
|
||||||
|
|
||||||
// Look for supported files
|
|
||||||
// If zero files are supported, hide the upload after a delay
|
|
||||||
|
|
||||||
let hasSupportedFiles = false
|
|
||||||
|
|
||||||
for (let i = 0; i < files.length; i++) {
|
|
||||||
|
|
||||||
if (files[i].supported===true) {
|
|
||||||
hasSupportedFiles = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasSupportedFiles===false) setTimeout(finish, 2000)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
formData.append('function', 'Photo::add')
|
formData.append('function', 'Photo::add')
|
||||||
formData.append('albumID', albumID)
|
formData.append('albumID', albumID)
|
||||||
@ -205,7 +178,7 @@ upload.start = {
|
|||||||
pre_progress = progress
|
pre_progress = progress
|
||||||
}
|
}
|
||||||
|
|
||||||
if (progress>=100) {
|
if (progress>=100 && next_file_started==false) {
|
||||||
|
|
||||||
// Scroll to the uploading file
|
// Scroll to the uploading file
|
||||||
let scrollPos = 0
|
let scrollPos = 0
|
||||||
@ -216,7 +189,10 @@ upload.start = {
|
|||||||
$('.basicModal .rows .row:nth-child(' + (file.num + 1) + ') .status').html('Processing')
|
$('.basicModal .rows .row:nth-child(' + (file.num + 1) + ') .status').html('Processing')
|
||||||
|
|
||||||
// Upload next file
|
// Upload next file
|
||||||
if (file.next!=null) process(files, file.next)
|
if (file.next!=null) {
|
||||||
|
process(files, file.next)
|
||||||
|
next_file_started = true
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,19 +209,9 @@ upload.start = {
|
|||||||
|
|
||||||
files[i].num = i
|
files[i].num = i
|
||||||
files[i].ready = false
|
files[i].ready = false
|
||||||
files[i].supported = true
|
|
||||||
|
|
||||||
if (i < files.length-1) files[i].next = files[i + 1]
|
if (i < files.length-1) files[i].next = files[i + 1]
|
||||||
else files[i].next = null
|
else files[i].next = null
|
||||||
|
|
||||||
// Check if file is supported
|
|
||||||
if (files[i].type!=='image/jpeg' && files[i].type!=='image/jpg' && files[i].type!=='image/png' && files[i].type!=='image/gif') {
|
|
||||||
|
|
||||||
files[i].ready = true
|
|
||||||
files[i].supported = false
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onbeforeunload = function() { return 'Lychee is currently uploading!' }
|
window.onbeforeunload = function() { return 'Lychee is currently uploading!' }
|
||||||
@ -276,8 +242,7 @@ upload.start = {
|
|||||||
basicModal.close()
|
basicModal.close()
|
||||||
|
|
||||||
files[0] = {
|
files[0] = {
|
||||||
name : data.link,
|
name : data.link
|
||||||
supported : true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
upload.show('Importing URL', files, function() {
|
upload.show('Importing URL', files, function() {
|
||||||
@ -356,8 +321,7 @@ upload.start = {
|
|||||||
let files = []
|
let files = []
|
||||||
|
|
||||||
files[0] = {
|
files[0] = {
|
||||||
name : data.path,
|
name : data.path
|
||||||
supported : true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
upload.show('Importing from server', files, function() {
|
upload.show('Importing from server', files, function() {
|
||||||
@ -466,8 +430,7 @@ upload.start = {
|
|||||||
links += files[i].link + ','
|
links += files[i].link + ','
|
||||||
|
|
||||||
files[i] = {
|
files[i] = {
|
||||||
name : files[i].link,
|
name : files[i].link
|
||||||
supported : true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user