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);
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) => {
let files = [];

View File

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

View File

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