RED-8375: fixed bugs.

This commit is contained in:
Nicoleta Panaghiu 2024-01-26 17:59:49 +02:00
parent 19fffc3102
commit 420bdde5d3
2 changed files with 15 additions and 23 deletions

View File

@ -597,27 +597,25 @@ export class FilePreviewScreenComponent
.pipe(tap(() => this._handleDeletedFile()))
.subscribe();
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$])
this.addActiveScreenSubscription = combineLatest([this._viewModeService.viewMode$, this.state.file$])
.pipe(
filter(([viewMode, file]) => viewMode === ViewModes.TEXT_HIGHLIGHTS && !file.hasHighlights),
tap(() => this._viewModeService.switchToStandard()),
)
.subscribe();
this.addActiveScreenSubscription = combineLatest([this._documentViewer.pageComplete$, this.state.updateExcludedPagesStyle$])
this.addActiveScreenSubscription = combineLatest([this._documentViewer.loaded$, this._viewModeService.viewMode$, this.state.file$])
.pipe(
filter(([loaded, viewMode, shouldUpdate]) => loaded && !!viewMode),
tap(async ([loaded, viewMode, shouldUpdate]) => {
if (loaded) {
await this._stampService.stampPDF();
}
}),
)
.subscribe();
this.addActiveScreenSubscription = combineLatest([this._documentViewer.pageComplete$, this.state.file$])
.pipe(tap(() => this._setExcludedPageStyles()))
.subscribe();

View File

@ -1,5 +1,5 @@
import { Injectable, Injector } from '@angular/core';
import { BehaviorSubject, combineLatest, firstValueFrom, from, merge, Observable, of, pairwise, Subject, switchMap } from 'rxjs';
import { 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,7 +37,6 @@ export class FilePreviewStateService {
readonly dossierFileChange$: Observable<File[]>;
readonly isReadonly$: Observable<boolean>;
readonly isWritable$: Observable<boolean>;
readonly updateExcludedPagesStyle$: Observable<number[]>;
readonly dossierId: string = getParam(DOSSIER_ID);
readonly dossierTemplateId: string = getParam(DOSSIER_TEMPLATE_ID);
@ -47,7 +46,6 @@ export class FilePreviewStateService {
file: File;
#dossierDictionary: Dictionary;
readonly #reloadBlob$ = new Subject();
readonly #updateExcludedPagesStyle$ = new BehaviorSubject([]);
constructor(
router: Router,
@ -63,12 +61,8 @@ 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)),
tap(file => this.#updateExcludedPagesStyle$.next(file.excludedPages)),
);
this.file$ = filesMapService.watch$(this.dossierId, this.fileId).pipe(tap(file => (this.file = file)));
[this.isReadonly$, this.isWritable$] = boolFactory(
combineLatest([this.file$, this.dossier$]),
([file, dossier]) => !permissionsService.canPerformAnnotationActions(file, dossier),