diff --git a/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.html b/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.html
index e7780c0ba..c285dab24 100644
--- a/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.html
+++ b/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.html
@@ -30,13 +30,13 @@
diff --git a/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.ts b/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.ts
index 8fdbb938d..3b083f9b4 100644
--- a/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.ts
+++ b/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.ts
@@ -110,6 +110,7 @@ export class FilePreviewScreenComponent implements OnInit {
this.loadingMessage = null;
this.canPerformAnnotationActions = this.permissionsService.canPerformAnnotationActions(this.fileData.fileStatus);
this._cleanupAndRedrawManualAnnotations();
+ this._fileDownloadService.loadRedactedView(this.fileData);
});
}
});
@@ -357,6 +358,9 @@ export class FilePreviewScreenComponent implements OnInit {
this.instance = $event;
this.viewReady = true;
this._cleanupAndRedrawManualAnnotations();
+ if (!this.fileData.redactedFileData) {
+ this._fileDownloadService.loadRedactedView(this.fileData);
+ }
}
filtersChanged(filters: FilterModel[]) {
@@ -371,9 +375,6 @@ export class FilePreviewScreenComponent implements OnInit {
}
private _cleanupAndRedrawManualAnnotations(annotationIdToDraw?: string) {
- if (!annotationIdToDraw) {
- this._fileDownloadService.loadRedactedView(this.fileData);
- }
this._fileDownloadService.loadActiveFileManualAnnotations().subscribe((manualRedactions) => {
this.fileData.manualRedactions = manualRedactions;
this._rebuildFilters();
@@ -414,4 +415,8 @@ export class FilePreviewScreenComponent implements OnInit {
isCategoryFilter(filter: FilterModel) {
return filter.filters && filter.filters.length > 0;
}
+
+ get displayData() {
+ return this.fileData ? (this.redactedView ? this.fileData.redactedFileData : this.fileData.annotatedFileData) : null;
+ }
}
diff --git a/apps/red-ui/src/app/screens/file/pdf-viewer/pdf-viewer.component.ts b/apps/red-ui/src/app/screens/file/pdf-viewer/pdf-viewer.component.ts
index 2ccf13878..9adc9071c 100644
--- a/apps/red-ui/src/app/screens/file/pdf-viewer/pdf-viewer.component.ts
+++ b/apps/red-ui/src/app/screens/file/pdf-viewer/pdf-viewer.component.ts
@@ -53,17 +53,13 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges {
) {}
ngOnInit() {
- this._restoreViewerState = this._restoreViewerState.bind(this);
+ this._documentLoaded = this._documentLoaded.bind(this);
}
ngOnChanges(changes: SimpleChanges): void {
if (this.instance) {
if (changes.fileData) {
- if (!this._viewerState) {
- this._loadDocument();
- } else {
- this._changeDocument();
- }
+ this._loadDocument();
}
if (changes.canPerformActions) {
this._handleCustomActions();
@@ -101,7 +97,7 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges {
this._ngZone.run(() => this.pageChanged.emit(p));
});
- instance.docViewer.on('documentLoaded', this._restoreViewerState);
+ instance.docViewer.on('documentLoaded', this._documentLoaded);
instance.docViewer.on('keyDown', ($event) => {
if ($event.key.startsWith('Arrow')) {
@@ -115,6 +111,9 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges {
}
});
+ // initialize state
+ this._restoreState(null, instance);
+
this._loadDocument();
});
}
@@ -237,16 +236,19 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges {
private _loadDocument() {
if (this.fileData) {
- console.log('load');
+ this._viewerState = this._getCurrentViewerState();
this.instance.loadDocument(this.fileData, {
filename: this.fileStatus ? this.fileStatus.filename : 'document.pdf'
});
}
}
- private _changeDocument() {
- // sync layout and display mode
+ private _documentLoaded() {
+ this.viewerReady.emit(this.instance);
+ this._restoreState(this._viewerState, this.instance);
+ }
+ private _getCurrentViewerState() {
const instance = this.instance;
const docViewer = this.instance.docViewer;
@@ -261,16 +263,7 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges {
zoom: docViewer.getZoom(),
leftPanelState: instance.isElementOpen('leftPanel')
};
-
- this._loadDocument();
-
- this._viewerState = viewerState;
- }
-
- private _restoreViewerState() {
- console.log('emit viewer ready');
- this.viewerReady.emit(this.instance);
- this._restoreState(this._viewerState, this.instance);
+ return viewerState;
}
private _restoreState(viewerState: ViewerState, instance: WebViewerInstance) {
@@ -294,6 +287,7 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges {
} else {
instance.closeElements(['leftPanel']);
}
+ this._viewerState = viewerState;
} else {
// viewer init
this.instance.setFitMode('FitPage');