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

Commit

Permalink
fix: correct constructor prop for adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsasharegan committed Feb 9, 2018
1 parent c6e2aef commit e1807fc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/classes/VTransmitFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ export class VTransmitFile {

startProgress(): VTransmitFile {
// Avoid starting twice
if (typeof this.upload.start !== "number") {
if (!this.upload.start) {
this.upload.start = Date.now();
}
return this;
}

endProgress(): VTransmitFile {
// Avoid ending twice
if (typeof this.upload.end !== "number") {
if (!this.upload.end) {
this.upload.end = Date.now();
this.upload.time = (Date.now() - this.upload.start) / 1000;
}
Expand Down
16 changes: 11 additions & 5 deletions src/components/VueTransmit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ export default Vue.extend({
default: objFactory,
},
uploadAdapter: {
type: Object,
type: Function,
default: XHRUploadAdapter,
},
},
Expand Down Expand Up @@ -409,10 +409,16 @@ export default Vue.extend({
};
},
transport(): UploaderInterface {
return new this.uploadAdapter(
new VTransmitUploadContext(this),
this.adapterOptions
);
let Adapter: any = this.uploadAdapter;
try {
return new Adapter(
new VTransmitUploadContext(this),
this.adapterOptions
);
} catch (err) {
console.error(err);
throw err;
}
},
},
Expand Down
10 changes: 6 additions & 4 deletions test/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
crossorigin="anonymous">
<link rel="stylesheet" href="https://unpkg.com/vue-flex/dist/vue-flex.css">
<script>
<?= file_get_contents(__DIR__. "/../dist/vue-transmit.browser.js" ); ?>
<?= file_get_contents(__DIR__. "/../dist/vue-transmit.js" ); ?>
</script>
<style>
#app {
Expand Down Expand Up @@ -178,9 +178,11 @@ class="ml-2 w-100"></b-progress>
return {
options: {
acceptedFileTypes: ['image/*'],
url: './upload.php',
clickable: false,
accept: this.accept
accept: this.accept,
adapterOptions: {
url: './upload.php',
},
},
files: [],
showModal: false,
Expand Down Expand Up @@ -215,7 +217,7 @@ class="ml-2 w-100"></b-progress>
accept(file, done) {
this.count++
console.log(JSON.stringify(file, undefined, 2))
done(this.count == 1)
done()
}
},
filters: {
Expand Down

0 comments on commit e1807fc

Please sign in to comment.