Skip to content

Commit

Permalink
Improve names
Browse files Browse the repository at this point in the history
Signed-off-by: Marco Ambrosini <marcoambrosini@pm.me>
  • Loading branch information
marcoambrosini committed Jul 27, 2020
1 parent 441f8b4 commit b6f3487
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/store/fileUploadStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const getters = {

uploadProgress: (state) => (uploadId, index) => {
if (state.uploads[uploadId].files[index]) {
return state.uploads[uploadId].files[index].progressLoaded / state.uploads[uploadId].files[index].progressTotal * 100
return state.uploads[uploadId].files[index].uploadedSize / state.uploads[uploadId].files[index].totalSize * 100
} else {
return 0
}
Expand Down Expand Up @@ -122,13 +122,13 @@ const mutations = {
},

// Sets the total size of the file in bytes
setProgressTotal(state, { uploadId, index, progressTotal }) {
Vue.set(state.uploads[uploadId].files[index], 'progressTotal', progressTotal)
setTotalSize(state, { uploadId, index, totalSize }) {
Vue.set(state.uploads[uploadId].files[index], 'totalSize', totalSize)
},

// Sets uploaded amount of bytes
setProgressLoaded(state, { uploadId, index, progressLoaded }) {
Vue.set(state.uploads[uploadId].files[index], 'progressLoaded', progressLoaded)
setUploadedSize(state, { uploadId, index, uploadedSize }) {
Vue.set(state.uploads[uploadId].files[index], 'uploadedSize', uploadedSize)
},
}

Expand Down Expand Up @@ -164,12 +164,12 @@ const actions = {
try {
// Upload the file
await client.putFileContents(userRoot + uniquePath, currentFile, { onUploadProgress: progress => {
const progressLoaded = progress.loaded
const progressTotal = progress.total
if (!state.uploads[uploadId].files[index].progressTotal) {
commit('setProgressTotal', { state, uploadId, index, progressTotal })
const uploadedSize = progress.loaded
const totalSize = progress.total
if (!state.uploads[uploadId].files[index].totalSize) {
commit('setTotalSize', { state, uploadId, index, totalSize })
}
commit('setProgressLoaded', { state, uploadId, index, progressLoaded })
commit('setUploadedSize', { state, uploadId, index, uploadedSize })
} })
// Path for the sharing request
const sharePath = '/' + uniquePath
Expand Down

0 comments on commit b6f3487

Please sign in to comment.