Skip to content

Commit 3802f03

Browse files
author
Walker Leite
committed
fix(component): fix not deleting all files in parallel
1 parent 1e1f699 commit 3802f03

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

src/ic-firebase-uploader/ic-firebase-uploader.vue

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
@click="onFileLinkClick(file.ref, $event)">
99
{{file.ref.name}}
1010
</a>
11-
<i class="fa fa-times ic-fb_uploader-delete" @click="onFileDeleteClick(file.ref)"></i>
11+
<i class="fa fa-times ic-fb_uploader-delete" @click="onFileDeleteClick(file)"></i>
1212
</li>
1313
</ul>
1414
<input
@@ -78,7 +78,7 @@ export default {
7878
getDownloadURL: fileRef.getDownloadURL,
7979
})
8080
},
81-
onFileDeleteClick(fileRef) {
81+
onFileDeleteClick(sentFile) {
8282
/**
8383
* This event is called before a file delete begins
8484
* call doDelete to continue. Properties in the
@@ -87,14 +87,15 @@ export default {
8787
* @type {Object}
8888
*/
8989
this.$emit('delete', {
90-
fullPath: fileRef.fullPath,
91-
doDelete: this.getDeleteFn(fileRef)
90+
fullPath: sentFile.ref.fullPath,
91+
doDelete: this.getDeleteFn(sentFile)
9292
})
9393
},
9494
onChangeLoader(event) {
9595
const files = event.target.files
96-
const curFilesLength = this.sentFiles.length + files.length
97-
if (curFilesLength > Number(this.maxFiles)) {
96+
const curFilesLength = this.sentFiles.length
97+
const afterFilesLength = curFilesLength + files.length
98+
if (afterFilesLength > Number(this.maxFiles)) {
9899
/**
99100
* Called when something wrong occurs, also,
100101
* it contains "maximum files reached" error when user tries to
@@ -152,11 +153,12 @@ export default {
152153
.catch(err => this.$emit('error', err))
153154
}
154155
},
155-
getDeleteFn(fileRef) {
156-
const sentIndex = this.sentFiles.indexOf(fileRef)
156+
getDeleteFn(file) {
157+
const fileRef = file.ref
157158
return () => {
158159
fileRef.delete()
159160
.then(() => {
161+
const sentIndex = this.sentFiles.indexOf(file)
160162
this.sentFiles.splice(sentIndex, 1)
161163
/**
162164
* This event is called after a file deletion ends.

0 commit comments

Comments
 (0)