From 19fffc31029a06aae804ff7b59a987f0ad5e2327 Mon Sep 17 00:00:00 2001 From: Nicoleta Panaghiu Date: Fri, 26 Jan 2024 17:21:46 +0200 Subject: [PATCH] RED-8375: backport watermark and border fix. --- .../file-preview-screen.component.ts | 19 +++++++++++++++---- .../services/file-preview-state.service.ts | 12 +++++++++--- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts b/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts index 3fef0d9ce..f06dde159 100644 --- a/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts @@ -597,7 +597,18 @@ export class FilePreviewScreenComponent .pipe(tap(() => this._handleDeletedFile())) .subscribe(); - const viewModeChanged$ = this._viewModeService.viewMode$.pipe(tap(() => this._stampService.stampPDF().then())); + const viewModeChanged$ = combineLatest([ + this._documentViewer.loaded$, + this._viewModeService.viewMode$, + this.state.updateExcludedPagesStyle$, + ]).pipe( + map(([loaded, viewMode, shouldUpdate]) => { + if (loaded) { + this._stampService.stampPDF().then(); + } + return viewMode; + }), + ); this.addActiveScreenSubscription = combineLatest([viewModeChanged$, this.state.file$]) .pipe( @@ -606,9 +617,9 @@ export class FilePreviewScreenComponent ) .subscribe(); - this.addActiveScreenSubscription = this._documentViewer.pageComplete$.subscribe(() => { - this._setExcludedPageStyles(); - }); + this.addActiveScreenSubscription = combineLatest([this._documentViewer.pageComplete$, this.state.updateExcludedPagesStyle$]) + .pipe(tap(() => this._setExcludedPageStyles())) + .subscribe(); this.addActiveScreenSubscription = this._documentViewer.keyUp$.subscribe($event => { this.handleKeyEvent($event); diff --git a/apps/red-ui/src/app/modules/file-preview/services/file-preview-state.service.ts b/apps/red-ui/src/app/modules/file-preview/services/file-preview-state.service.ts index a1e6d8d81..cc23d5856 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/file-preview-state.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/file-preview-state.service.ts @@ -1,5 +1,5 @@ import { Injectable, Injector } from '@angular/core'; -import { combineLatest, firstValueFrom, from, merge, Observable, of, pairwise, Subject, switchMap } from 'rxjs'; +import { BehaviorSubject, combineLatest, firstValueFrom, from, merge, Observable, of, pairwise, Subject, switchMap } from 'rxjs'; import { Dictionary, Dossier, DOSSIER_ID, DOSSIER_TEMPLATE_ID, File, FILE_ID } from '@red/domain'; import { Router } from '@angular/router'; import { FilesMapService } from '@services/files/files-map.service'; @@ -37,6 +37,7 @@ export class FilePreviewStateService { readonly dossierFileChange$: Observable; readonly isReadonly$: Observable; readonly isWritable$: Observable; + readonly updateExcludedPagesStyle$: Observable; readonly dossierId: string = getParam(DOSSIER_ID); readonly dossierTemplateId: string = getParam(DOSSIER_TEMPLATE_ID); @@ -46,12 +47,13 @@ export class FilePreviewStateService { file: File; #dossierDictionary: Dictionary; readonly #reloadBlob$ = new Subject(); + readonly #updateExcludedPagesStyle$ = new BehaviorSubject([]); constructor( router: Router, filesMapService: FilesMapService, - private readonly _injector: Injector, permissionsService: PermissionsService, + private readonly _injector: Injector, private readonly _filesService: FilesService, private readonly _dossiersService: DossiersService, private readonly _fileManagementService: FileManagementService, @@ -61,8 +63,12 @@ export class FilePreviewStateService { private readonly _loadingService: LoadingService, ) { const dossiersService = dossiersServiceResolver(_injector, router); + this.updateExcludedPagesStyle$ = this.#updateExcludedPagesStyle$.asObservable(); this.dossier$ = dossiersService.getEntityChanged$(this.dossierId).pipe(tap(dossier => (this.dossier = dossier))); - this.file$ = filesMapService.watch$(this.dossierId, this.fileId).pipe(tap(file => (this.file = file))); + this.file$ = filesMapService.watch$(this.dossierId, this.fileId).pipe( + tap(file => (this.file = file)), + tap(file => this.#updateExcludedPagesStyle$.next(file.excludedPages)), + ); [this.isReadonly$, this.isWritable$] = boolFactory( combineLatest([this.file$, this.dossier$]), ([file, dossier]) => !permissionsService.canPerformAnnotationActions(file, dossier),