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(); .subscribe();
this.addActiveScreenSubscription = this._readableRedactionsService.active$.pipe(switchMap(() => this.updateViewMode())).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( .pipe(
tap(([viewMode]) => map(
viewMode === 'STANDARD' || viewMode === 'TEXT_HIGHLIGHTS' ([viewMode, file]) => ['STANDARD', 'TEXT_HIGHLIGHTS'].includes(viewMode) && this.permissionsService.canRotatePage(file),
? this._viewerHeaderService.updateRotationButtons(true) ),
: this._viewerHeaderService.updateRotationButtons(false), tap(canRotate =>
canRotate ? this._viewerHeaderService.enableRotationButtons() : this._viewerHeaderService.disableRotationButtons(),
), ),
) )
.subscribe(); .subscribe();

View File

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