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

View file

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