Skip to content
This repository has been archived by the owner on Jan 29, 2019. It is now read-only.

Commit

Permalink
fix: improve typings and ensure removeFile returns void
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsasharegan committed Oct 17, 2017
1 parent 8a100f7 commit 0a3f686
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/components/VueTransmit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ export default class VueTransmit extends Vue {
// Used to keep the createThumbnail calls processing async one-at-a-time
private processingThumbnail: boolean = false
public thumbnailQueue: any[] = []
public files: any[] = []
public files: VTransmitFile[] = []
public defaultHeaders: object = {
"Accept": "application/json",
"Cache-Control": "no-cache",
Expand Down Expand Up @@ -339,13 +339,13 @@ export default class VueTransmit extends Vue {
}
}
getFilesWithStatus(...statuses: string[]) {
getFilesWithStatus(...statuses: string[]): VTransmitFile[] {
return this.files.filter(f => statuses.includes(f.status))
}
onFileInputChange() {
onFileInputChange(): void {
this.$emit('added-files', Array.from(this.inputEl.files).map(this.addFile))
}
addFile(file: File) {
addFile(file: File): VTransmitFile {
const vTransmitFile = VTransmitFile.fromNativeFile(file)
vTransmitFile.status = STATUSES.ADDED
this.files.push(vTransmitFile)
Expand All @@ -368,29 +368,29 @@ export default class VueTransmit extends Vue {
return vTransmitFile
}
removeFile(file: VTransmitFile) {
removeFile(file: VTransmitFile): void {
if (file.status === STATUSES.UPLOADING) {
this.cancelUpload(file)
}
const idxToRm = this.files.findIndex(f => f.id === file.id)
if (~idxToRm) {
this.$emit("removed-file", this.files.splice(idxToRm, 1)[0])
if (this.files.length === 0) {
return this.$emit("reset")
this.$emit("reset")
}
}
}
removeAllFiles(cancelInProgressUploads = false) {
removeAllFiles(cancelInProgressUploads = false): void {
for (const file of this.files) {
if (file.status !== STATUSES.UPLOADING || cancelInProgressUploads) {
this.removeFile(file)
}
}
}
triggerBrowseFiles() {
triggerBrowseFiles(): void {
this.inputEl.click()
}
handleClickUploaderAction() {
handleClickUploaderAction(): void {
if (this.clickable) {
this.triggerBrowseFiles()
}
Expand Down

0 comments on commit 0a3f686

Please sign in to comment.