diff --git a/apps/red-ui/src/app/modules/dossier/components/pdf-viewer/pdf-viewer.component.ts b/apps/red-ui/src/app/modules/dossier/components/pdf-viewer/pdf-viewer.component.ts index d0c903424..18d43d079 100644 --- a/apps/red-ui/src/app/modules/dossier/components/pdf-viewer/pdf-viewer.component.ts +++ b/apps/red-ui/src/app/modules/dossier/components/pdf-viewer/pdf-viewer.component.ts @@ -32,6 +32,7 @@ import { PdfViewerUtils } from '../../utils/pdf-viewer.utils'; import { ViewMode } from '@models/file/view-mode'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; import TextTool = Tools.TextTool; +import { ActivatedRoute } from '@angular/router'; @Component({ selector: 'redaction-pdf-viewer', @@ -57,6 +58,7 @@ export class PdfViewerComponent implements OnInit, OnChanges { instance: WebViewerInstance; utils: PdfViewerUtils; private _selectedText = ''; + private _firstPageChange = true; private readonly _allowedKeyboardShortcuts = ['+', '-', 'p', 'r', 'Escape']; constructor( @@ -65,6 +67,7 @@ export class PdfViewerComponent implements OnInit, OnChanges { private readonly _manualAnnotationService: ManualAnnotationService, private readonly _dialogService: DossiersDialogService, private readonly _ngZone: NgZone, + private readonly _activatedRoute: ActivatedRoute, private readonly _userPreferenceService: UserPreferenceService, private readonly _annotationDrawService: AnnotationDrawService, private readonly _annotationActionsService: AnnotationActionsService, @@ -236,7 +239,15 @@ export class PdfViewerComponent implements OnInit, OnChanges { if (this.shouldDeselectAnnotationsOnPageChange) { this.utils.deselectAllAnnotations(); } - this._ngZone.run(() => this.pageChanged.emit(pageNumber)); + if (this._firstPageChange && pageNumber === 1) { + this._firstPageChange = false; + const routePageNumber = this._activatedRoute.snapshot.queryParams.page; + if (pageNumber) { + this.utils.navigateToPage(parseInt(routePageNumber, 10)); + } + } else { + this._ngZone.run(() => this.pageChanged.emit(pageNumber)); + } }); this.instance.docViewer.on('documentLoaded', this._documentLoaded); @@ -565,6 +576,7 @@ export class PdfViewerComponent implements OnInit, OnChanges { private _documentLoaded(): void { this._ngZone.run(() => { this.utils.ready = true; + this._firstPageChange = true; this.viewerReady.emit(this.instance); this.setInitialViewerState(); }); diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts index dce9ae478..c877dfceb 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts @@ -245,7 +245,6 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni this.displayPDFViewer = true; this._updateCanPerformActions(); this._subscribeToFileUpdates(); - this._loadingService.stop(); } rebuildFilters(deletePreviousAnnotations: boolean = false) { @@ -398,14 +397,17 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni await this._stampExcludedPages(); this._cleanupAndRedrawManualAnnotations(); this._updateCanPerformActions(); - this._loadingService.stop(); + // Go to initial page from query params const pageNumber = this._lastPage || this._activatedRoute.snapshot.queryParams.page; if (pageNumber) { setTimeout(() => { this.selectPage(parseInt(pageNumber, 10)); this._scrollViews(); - }, 600); + this._loadingService.stop(); + }); + } else { + this._loadingService.stop(); } } @@ -423,14 +425,14 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni case 'enable-analysis': case 'reanalyse': - await this._loadFileData(); + await this._loadFileData(true); this._updateCanPerformActions(); await this.appStateService.reloadActiveDossierFiles(); return; case 'exclude-pages': await this.appStateService.reloadActiveDossierFiles(); - await this._loadFileData(); + await this._loadFileData(true); this._loadingService.stop(); return; diff --git a/libs/common-ui b/libs/common-ui index 0bb0e4454..1d46b21c7 160000 --- a/libs/common-ui +++ b/libs/common-ui @@ -1 +1 @@ -Subproject commit 0bb0e4454f3015d1c81ccd23415c8135c89eeeff +Subproject commit 1d46b21c74c07d6811a99b9de6c940c740bc8ceb