From 81e0498e48af87758892771a7c0b0dd19fa020c9 Mon Sep 17 00:00:00 2001 From: Dan Percic Date: Mon, 19 Apr 2021 17:24:34 +0300 Subject: [PATCH] throws undefined error --- .../components/pdf-viewer/pdf-viewer.component.ts | 2 +- .../file-preview-screen.component.ts | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/apps/red-ui/src/app/modules/projects/components/pdf-viewer/pdf-viewer.component.ts b/apps/red-ui/src/app/modules/projects/components/pdf-viewer/pdf-viewer.component.ts index f576348bf..4212715f1 100644 --- a/apps/red-ui/src/app/modules/projects/components/pdf-viewer/pdf-viewer.component.ts +++ b/apps/red-ui/src/app/modules/projects/components/pdf-viewer/pdf-viewer.component.ts @@ -418,7 +418,7 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges { } } - private _loadDocument() { + public _loadDocument() { if (this.fileData) { this.instance.loadDocument(this.fileData, { filename: this.fileStatus ? this.fileStatus.filename : 'document.pdf' diff --git a/apps/red-ui/src/app/modules/projects/screens/file-preview-screen/file-preview-screen.component.ts b/apps/red-ui/src/app/modules/projects/screens/file-preview-screen/file-preview-screen.component.ts index 87e8002e1..4974a55f4 100644 --- a/apps/red-ui/src/app/modules/projects/screens/file-preview-screen/file-preview-screen.component.ts +++ b/apps/red-ui/src/app/modules/projects/screens/file-preview-screen/file-preview-screen.component.ts @@ -1,5 +1,5 @@ import { ChangeDetectorRef, Component, HostListener, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core'; -import { ActivatedRoute, Router } from '@angular/router'; +import { ActivatedRoute, Event, NavigationEnd, Router } from '@angular/router'; import { AppStateService } from '../../../../state/app-state.service'; import { WebViewerInstance } from '@pdftron/webviewer'; import { PdfViewerComponent } from '../../components/pdf-viewer/pdf-viewer.component'; @@ -191,6 +191,15 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy { }); } }); + + this._router.events.subscribe((event: Event) => { + if (event instanceof NavigationEnd) { + console.log(event); + if (!event.url.includes('?page=') && event.url.includes('/ui/projects/') && event.url.includes('/file/')) { + this._viewerComponent._loadDocument(); + } + } + }); } ngOnDestroy(): void {