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 { PdfPasswordDialogComponent } from './pdf-viewer-password-dialog';
|
||||||
import { AppConfigService } from './../../app-config/app-config.service';
|
import { AppConfigService } from './../../app-config/app-config.service';
|
||||||
import { PDFDocumentProxy, PDFSource } from 'pdfjs-dist';
|
import { PDFDocumentProxy, PDFSource } from 'pdfjs-dist';
|
||||||
|
import { timer } from 'rxjs';
|
||||||
|
|
||||||
declare const pdfjsLib: any;
|
declare const pdfjsLib: any;
|
||||||
declare const pdfjsViewer: any;
|
declare const pdfjsViewer: any;
|
||||||
@@ -236,14 +237,14 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.loadingTask) {
|
if (this.loadingTask) {
|
||||||
try {
|
timer(700).subscribe(() => this.destroyPdJsWorker());
|
||||||
this.loadingTask.destroy();
|
}
|
||||||
} catch {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private destroyPdJsWorker() {
|
||||||
|
this.loadingTask.destroy();
|
||||||
this.loadingTask = null;
|
this.loadingTask = null;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
toggleThumbnails() {
|
toggleThumbnails() {
|
||||||
this.showThumbnails = !this.showThumbnails;
|
this.showThumbnails = !this.showThumbnails;
|
||||||
|
Reference in New Issue
Block a user