[ADF-5173] - delayed destroying of pdfjs worker to prevent error on c… (#7062)

* [ADF-5173] - delayed destroying of pdfjs worker to prevent error on closing while loading

* [ADF-5173] - added delay instead of setTimeout

* Update pdf-viewer.component.ts

Co-authored-by: Eugenio Romano <eromano@users.noreply.github.com>
This commit is contained in:
Vito
2021-07-13 13:49:41 +01:00
committed by GitHub
parent 8be6bbaf3c
commit 3d94711326

View File

@@ -33,6 +33,7 @@ import { RenderingQueueServices } from '../services/rendering-queue.services';
import { PdfPasswordDialogComponent } from './pdf-viewer-password-dialog';
import { AppConfigService } from './../../app-config/app-config.service';
import { PDFDocumentProxy, PDFSource } from 'pdfjs-dist';
import { timer } from 'rxjs';
declare const pdfjsLib: any;
declare const pdfjsViewer: any;
@@ -236,14 +237,14 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
}
if (this.loadingTask) {
try {
this.loadingTask.destroy();
} catch {
timer(700).subscribe(() => this.destroyPdJsWorker());
}
}
private destroyPdJsWorker() {
this.loadingTask.destroy();
this.loadingTask = null;
}
}
toggleThumbnails() {
this.showThumbnails = !this.showThumbnails;