Skip to content

Commit

Permalink
fix for restarting cancel upload
Browse files Browse the repository at this point in the history
  • Loading branch information
alichherawalla authored and jkuri committed Oct 23, 2018
1 parent 2da582c commit fa24576
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions projects/ngx-uploader/src/lib/ngx-uploader.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,17 @@ export class NgUploaderService {
if (!id) {
return;
}

const index = this.subs.findIndex(sub => sub.id === id);
if (index !== -1 && this.subs[index].sub) {
this.subs[index].sub.unsubscribe();

const fileIndex = this.queue.findIndex(file => file.id === id);
if (fileIndex !== -1) {
this.queue[fileIndex].progress.status = UploadStatus.Cancelled;
this.serviceEvents.emit({ type: 'cancelled', file: this.queue[fileIndex] });
const subs = this.subs.filter(sub => sub.id === id);
subs.forEach(sub => {
if (sub.sub) {
sub.sub.unsubscribe();
const fileIndex = this.queue.findIndex(file => file.id === id);
if (fileIndex !== -1) {
this.queue[fileIndex].progress.status = UploadStatus.Cancelled;
this.serviceEvents.emit({type: 'cancelled', file: this.queue[fileIndex]});
}
}
}
});
break;
case 'cancelAll':
this.subs.forEach(sub => {
Expand Down

0 comments on commit fa24576

Please sign in to comment.