RED-6316: Small refactor

This commit is contained in:
Adina Țeudan 2023-03-16 21:47:07 +02:00
parent ebcf83703a
commit e92cbbf94d
2 changed files with 14 additions and 16 deletions

View File

@ -690,12 +690,14 @@ export class FilePreviewScreenComponent
.subscribe();
this.addActiveScreenSubscription = this._readableRedactionsService.active$.pipe(switchMap(() => this.updateViewMode())).subscribe();
this.addActiveScreenSubscription = combineLatest([this._viewModeService.viewMode$, this._documentViewer.loaded$, this.state.file$])
this.addActiveScreenSubscription = combineLatest([this._viewModeService.viewMode$, this.state.file$, this._documentViewer.loaded$])
.pipe(
tap(([viewMode]) =>
viewMode === 'STANDARD' || viewMode === 'TEXT_HIGHLIGHTS'
? this._viewerHeaderService.updateRotationButtons(true)
: this._viewerHeaderService.updateRotationButtons(false),
map(
([viewMode, file]) => ['STANDARD', 'TEXT_HIGHLIGHTS'].includes(viewMode) && this.permissionsService.canRotatePage(file),
),
tap(canRotate =>
canRotate ? this._viewerHeaderService.enableRotationButtons() : this._viewerHeaderService.disableRotationButtons(),
),
)
.subscribe();

View File

@ -14,7 +14,6 @@ import { fromEvent, Observable, Subject } from 'rxjs';
import { ViewerEvent, VisibilityChangedEvent } from '../utils/types';
import { ReadableRedactionsService } from './readable-redactions.service';
import { filter, map, tap } from 'rxjs/operators';
import { PermissionsService } from '@services/permissions.service';
const divider: IHeaderElement = {
type: 'divider',
@ -50,7 +49,6 @@ export class ViewerHeaderService {
private readonly _tooltipsService: TooltipsService,
private readonly _readableRedactionsService: ReadableRedactionsService,
private readonly _userPreferenceService: UserPreferenceService,
private readonly _permissionsService: PermissionsService,
) {
this.events$ = this.#events$.asObservable();
}
@ -299,15 +297,13 @@ export class ViewerHeaderService {
});
}
updateRotationButtons(show: boolean): void {
const { dossierId, fileId } = this._pdf;
const file = this._filesMapService.get(dossierId, fileId);
if (show && this._permissionsService.canRotatePage(file)) {
this.enable(ROTATION_BUTTONS);
} else {
this.disable(ROTATION_BUTTONS);
this.#discardRotation();
}
enableRotationButtons(): void {
this.enable(ROTATION_BUTTONS);
}
disableRotationButtons(): void {
this.disable(ROTATION_BUTTONS);
this.#discardRotation();
}
resetCompareButtons() {