Skip to content

Commit

Permalink
fix: update autoUoloadFiles method to put as queue the added files
Browse files Browse the repository at this point in the history
  • Loading branch information
wil92 committed Feb 25, 2019
1 parent 583e6cb commit 301a2b5
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/uploadx/src/uploadx.service.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import {Injectable} from '@angular/core';
import { Injectable } from '@angular/core';

import { Subject, Observable } from 'rxjs';

import {UploadxOptions, UploadState, UploadxControlEvent, UploaderOptions, UploadStatus} from './interfaces';
import {
UploadxOptions,
UploadState,
UploadxControlEvent,
UploaderOptions,
UploadStatus
} from './interfaces';
import { Uploader } from './uploader';
/**
*
Expand Down Expand Up @@ -31,7 +37,11 @@ export class UploadxService {

constructor() {
this.subj.subscribe((uploadState: UploadState) => {
if (uploadState.status === 'complete' || uploadState.status === 'cancelled' || uploadState.status === 'error') {
if (
uploadState.status === 'complete' ||
uploadState.status === 'cancelled' ||
uploadState.status === 'error'
) {
this.autoUploadFiles();
}
});
Expand Down Expand Up @@ -71,6 +81,7 @@ export class UploadxService {
*/
private autoUploadFiles() {
if (this.autoUpload) {
this.queue.filter(f => f.status === 'added').forEach(f => (f.status = 'queue'));
this.processQueue();
}
}
Expand Down Expand Up @@ -101,7 +112,7 @@ export class UploadxService {
const upload = this.queue.find(f => f.uploadId === uploadId);
if (this.concurrency - this.runningProcess() > 0) {
upload.upload(event.itemOptions);
} else if (upload.status === 'added' as UploadStatus) {
} else if (upload.status === ('added' as UploadStatus)) {
upload.status = 'queue' as UploadStatus;
}
break;
Expand Down

0 comments on commit 301a2b5

Please sign in to comment.