mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[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:
@@ -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,15 +237,15 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
|
||||
}
|
||||
|
||||
if (this.loadingTask) {
|
||||
try {
|
||||
this.loadingTask.destroy();
|
||||
} catch {
|
||||
}
|
||||
|
||||
this.loadingTask = null;
|
||||
timer(700).subscribe(() => this.destroyPdJsWorker());
|
||||
}
|
||||
}
|
||||
|
||||
private destroyPdJsWorker() {
|
||||
this.loadingTask.destroy();
|
||||
this.loadingTask = null;
|
||||
}
|
||||
|
||||
toggleThumbnails() {
|
||||
this.showThumbnails = !this.showThumbnails;
|
||||
}
|
||||
|
Reference in New Issue
Block a user