disable upload button while uploading. fixes #927

This commit is contained in:
Danny Coates 2018-09-18 12:56:42 -07:00
parent 3d2c8c2ce2
commit 17a0393ce0
No known key found for this signature in database
GPG Key ID: 4C442633C62E00CB
1 changed files with 13 additions and 9 deletions

View File

@ -78,7 +78,7 @@ module.exports = function(state, emit) {
<button <button
class="btn ${btnUploading} ${sendFileClass}" class="btn ${btnUploading} ${sendFileClass}"
onclick=${upload} onclick=${state.uploading ? noop : upload}
title="${btnText}"> title="${btnText}">
${btnText} ${btnText}
</button> </button>
@ -91,6 +91,8 @@ module.exports = function(state, emit) {
</div> </div>
`; `;
function noop() {}
function dragover(event) { function dragover(event) {
const div = document.querySelector('.uploadArea'); const div = document.querySelector('.uploadArea');
div.classList.add('uploadArea--dragging'); div.classList.add('uploadArea--dragging');
@ -117,20 +119,22 @@ module.exports = function(state, emit) {
} }
} }
async function addFiles(event) { function addFiles(event) {
event.preventDefault(); event.preventDefault();
const newFiles = Array.from(event.target.files); const newFiles = Array.from(event.target.files);
emit('addFiles', { files: newFiles }); emit('addFiles', { files: newFiles });
} }
async function upload(event) { function upload(event) {
event.preventDefault(); event.preventDefault();
event.target.disabled = true;
if (!state.uploading) {
emit('upload', { emit('upload', {
type: 'click', type: 'click',
dlimit: state.downloadCount || 1, dlimit: state.downloadCount || 1,
password: state.password password: state.password
}); });
} }
}
}; };