fix: show real files remaining in upload counter

This commit is contained in:
filippofinke 2022-02-15 22:55:26 +01:00
parent 3c335cfb37
commit 7a968bccd9
3 changed files with 12 additions and 6 deletions

View File

@ -13,6 +13,13 @@ const getters = {
let sum = state.upload.progress.reduce((acc, val) => acc + val); let sum = state.upload.progress.reduce((acc, val) => acc + val);
return Math.ceil((sum / totalSize) * 100); return Math.ceil((sum / totalSize) * 100);
}, },
filesInUploadCount: (state) => {
console.log("uploads", Object.keys(state.upload.uploads));
console.log("queue", state.upload.queue);
console.log(Object.keys(state.upload.uploads).length + state.upload.queue.length);
let total = Object.keys(state.upload.uploads).length + state.upload.queue.length;
return total;
},
filesInUpload: (state) => { filesInUpload: (state) => {
let files = []; let files = [];

View File

@ -33,6 +33,7 @@ const mutations = {
Vue.set(state.uploads, item.id, item); Vue.set(state.uploads, item.id, item);
}, },
removeJob(state, id) { removeJob(state, id) {
Vue.delete(state.uploads, id);
delete state.uploads[id]; delete state.uploads[id];
}, },
}; };
@ -96,9 +97,7 @@ const actions = {
{ leading: true, trailing: false } { leading: true, trailing: false }
); );
await api await api.post(item.path, item.file, item.overwrite, onUpload).catch(Vue.prototype.$showError);
.post(item.path, item.file, item.overwrite, onUpload)
.catch(Vue.prototype.$showError);
} }
context.dispatch("finishUpload", item); context.dispatch("finishUpload", item);

View File

@ -21,7 +21,7 @@
icon="file_upload" icon="file_upload"
id="upload-button" id="upload-button"
:label="$t('buttons.upload')" :label="$t('buttons.upload')"
:counter="filesInUpload.length" :counter="filesInUploadCount"
@action="upload" @action="upload"
/> />
<action icon="info" :label="$t('buttons.info')" show="info" /> <action icon="info" :label="$t('buttons.info')" show="info" />
@ -182,7 +182,7 @@ export default {
}, },
computed: { computed: {
...mapState(["req", "selected", "user", "show", "multiple", "selected", "loading"]), ...mapState(["req", "selected", "user", "show", "multiple", "selected", "loading"]),
...mapGetters(["selectedCount", "filesInUpload"]), ...mapGetters(["selectedCount", "filesInUploadCount"]),
nameSorted() { nameSorted() {
return this.req.sorting.by === "name"; return this.req.sorting.by === "name";
}, },
@ -701,7 +701,7 @@ export default {
this.fillWindow(); this.fillWindow();
}, },
upload: function () { upload: function () {
if (this.filesInUpload.length > 0) { if (this.filesInUploadCount > 0) {
this.$store.commit("showHover", "uploadFiles"); this.$store.commit("showHover", "uploadFiles");
} else { } else {
if (typeof window.DataTransferItem !== "undefined" && typeof DataTransferItem.prototype.webkitGetAsEntry !== "undefined") { if (typeof window.DataTransferItem !== "undefined" && typeof DataTransferItem.prototype.webkitGetAsEntry !== "undefined") {