[ADF-5173] - improved fix for closing pdfjs worker error (#7225)

* [ACA-3847] - fixed download for external source file

* [ADF-5173] - improved fix for closing pdfjs worker error

* Fixed lint error
This commit is contained in:
Vito 2021-09-28 11:47:04 +01:00 committed by GitHub
parent df08e36d24
commit f963c6d15e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 6 deletions

2
.gitignore vendored
View File

@ -9,6 +9,7 @@ workspace.xml
dist/
e2e/.env.cloud
tmp
temp
e2e-output*/
/e2e/downloads/
*.npmrc
@ -28,3 +29,4 @@ out-tsc
/reports/
e2e-result-*
licenses.txt
.DS_Store

View File

@ -33,7 +33,8 @@ 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';
import { Subject } from 'rxjs';
import { catchError, delay, takeUntil } from 'rxjs/operators';
declare const pdfjsLib: any;
declare const pdfjsViewer: any;
@ -106,6 +107,8 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
disableAutoFetch: true,
disableStream: true
};
private pdfjsWorkerDestroy$ = new Subject<boolean>();
private onDestroy$ = new Subject<boolean>();
constructor(
private dialog: MatDialog,
@ -118,6 +121,7 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
this.onPageRendered = this.onPageRendered.bind(this);
this.randomPdfId = this.generateUuid();
this.currentScale = this.getUserScaling();
this.pdfjsWorkerDestroy$.pipe(catchError(() => null), delay(700), takeUntil(this.onDestroy$)).subscribe(() => this.destroyPdJsWorker());
}
getUserScaling(): number {
@ -237,8 +241,11 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
}
if (this.loadingTask) {
timer(700).subscribe(() => this.destroyPdJsWorker());
this.pdfjsWorkerDestroy$.next();
}
this.onDestroy$.next();
this.pdfjsWorkerDestroy$.complete();
this.onDestroy$.complete();
}
private destroyPdJsWorker() {

View File

@ -45,7 +45,7 @@ export class AttachFileWidgetDialogService {
* @param currentFolderId Upload file from specific folder
* @returns Information about the chosen file(s)
*/
openLogin(repository: AlfrescoEndpointRepresentation, currentFolderId = '-my-'): Observable<Node[]> {
openLogin(repository: AlfrescoEndpointRepresentation, currentFolderId = '-my-', accountIdentifier?: string): Observable<Node[]> {
const { title, ecmHost, selected, registerExternalHost } = this.constructPayload(repository);
const data: AttachFileWidgetDialogComponentData = {
title,
@ -54,7 +54,8 @@ export class AttachFileWidgetDialogService {
currentFolderId,
isSelectionValid: (entry: Node) => entry.isFile,
showFilesInResult: true,
registerExternalHost
registerExternalHost,
accountIdentifier
};
this.openLoginDialog(data, 'adf-attach-file-widget-dialog', '630px');

View File

@ -238,11 +238,12 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements
}
private uploadFileFromExternalCS(repository: AlfrescoEndpointRepresentation, currentFolderId?: string) {
this.attachDialogService.openLogin(repository, currentFolderId).subscribe(
const accountIdentifier = `alfresco-${repository.id}-${repository.name}`;
this.attachDialogService.openLogin(repository, currentFolderId, accountIdentifier).subscribe(
(selections: any[]) => {
selections.forEach((node) => node.isExternal = true);
this.tempFilesList.push(...selections);
this.uploadFileFromCS(selections, `alfresco-${repository.id}-${repository.name}`);
this.uploadFileFromCS(selections, accountIdentifier);
});
}