reload file when applying rotation

This commit is contained in:
Dan Percic 2022-04-04 16:53:19 +03:00
parent cee84ab3a0
commit 609ee147fe
4 changed files with 21 additions and 15 deletions

View File

@ -138,7 +138,7 @@ export class AnnotationDrawService {
private _computeAnnotation(annotationWrapper: AnnotationWrapper) {
const pageNumber = this._viewModeService.isCompare ? annotationWrapper.pageNumber * 2 - 1 : annotationWrapper.pageNumber;
if (pageNumber > this._pdf.documentViewer.getPageCount()) {
if (pageNumber > this._pdf.pageCount) {
// skip imported annotations from files that have more pages than the current one
return;
}

View File

@ -1,10 +1,9 @@
import { Injectable } from '@angular/core';
import { BehaviorSubject, firstValueFrom, of } from 'rxjs';
import { PermissionsService } from '@services/permissions.service';
import { RotationType, RotationTypes } from '@red/domain';
import { FileManagementService } from '@services/entity-services/file-management.service';
import { FilePreviewStateService } from './file-preview-state.service';
import { distinctUntilChanged, map, tap } from 'rxjs/operators';
import { distinctUntilChanged, map, switchMap, tap, withLatestFrom } from 'rxjs/operators';
import { PdfViewer } from './pdf-viewer.service';
import { HeaderElements } from '../shared/constants';
import {
@ -17,6 +16,7 @@ import {
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { MatDialog } from '@angular/material/dialog';
import { ViewerHeaderConfigService } from './viewer-header-config.service';
import { FilesService } from '../../../services/entity-services/files.service';
const ACTION_BUTTONS = [HeaderElements.APPLY_ROTATION, HeaderElements.DISCARD_ROTATION];
const ONE_ROTATION_DEGREE = 90;
@ -30,8 +30,8 @@ export class PageRotationService {
private readonly _dialog: MatDialog,
private readonly _loadingService: LoadingService,
private readonly _screenState: FilePreviewStateService,
private readonly _permissionsService: PermissionsService,
private readonly _fileManagementService: FileManagementService,
private readonly _filesService: FilesService,
private readonly _headerConfigService: ViewerHeaderConfigService,
) {}
@ -53,7 +53,13 @@ export class PageRotationService {
const request = this._fileManagementService.rotatePage({ pages }, dossierId, fileId);
this.clearRotationsHideActions();
return firstValueFrom(request.pipe(tap(() => this._loadingService.stop())));
return firstValueFrom(
request.pipe(
withLatestFrom(this._screenState.file$),
switchMap(([, file]) => this._filesService.reload(dossierId, file)),
tap(() => this._loadingService.stop()),
),
);
}
discardRotation() {

View File

@ -64,22 +64,22 @@ export class PdfViewer {
}
get totalPages() {
return this._viewModeService.isCompare ? Math.ceil(this._totalInternalPages / 2) : this._totalInternalPages;
return this._viewModeService.isCompare ? Math.ceil(this.pageCount / 2) : this.pageCount;
}
private get _currentInternalPage() {
return this.documentViewer?.getCurrentPage() ?? 1;
}
private get _totalInternalPages() {
get pageCount() {
try {
return this.documentViewer?.getPageCount() ?? 1;
return this.instance?.Core.documentViewer?.getPageCount() ?? 1;
} catch {
// might throw Error: getPageCount was called before the 'documentLoaded' event
return 1;
}
}
private get _currentInternalPage() {
return this.instance?.Core.documentViewer?.getCurrentPage() ?? 1;
}
async lockDocument() {
const document = await this.documentViewer.getDocument()?.getPDFDoc();
if (!document) {
@ -160,8 +160,8 @@ export class PdfViewer {
}
navigateNextPage() {
if (this._currentInternalPage < this._totalInternalPages) {
this._navigateToPage(Math.min(this._currentInternalPage + this.paginationOffset, this._totalInternalPages));
if (this._currentInternalPage < this.pageCount) {
this._navigateToPage(Math.min(this._currentInternalPage + this.paginationOffset, this.pageCount));
}
}

@ -1 +1 @@
Subproject commit 8e15298919c2ae3b0abb243c3c6912eb97d6db68
Subproject commit 1e6ebf252fa3be1704595d42dc621380a0d07ca0