added throttle and handling for missing annotations
This commit is contained in:
parent
888c57c5f0
commit
355b197220
@ -5,14 +5,14 @@ import {
|
|||||||
HostListener,
|
HostListener,
|
||||||
NgZone,
|
NgZone,
|
||||||
OnInit,
|
OnInit,
|
||||||
ViewChild
|
ViewChild,
|
||||||
|
EventEmitter
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import {
|
import {
|
||||||
DictionaryControllerService,
|
DictionaryControllerService,
|
||||||
ManualRedactionEntry,
|
ManualRedactionEntry,
|
||||||
ReanalysisControllerService,
|
ReanalysisControllerService
|
||||||
TypeValue
|
|
||||||
} from '@redaction/red-ui-http';
|
} from '@redaction/red-ui-http';
|
||||||
import { AppStateService } from '../../../state/app-state.service';
|
import { AppStateService } from '../../../state/app-state.service';
|
||||||
import { Annotations, WebViewerInstance } from '@pdftron/webviewer';
|
import { Annotations, WebViewerInstance } from '@pdftron/webviewer';
|
||||||
@ -461,7 +461,6 @@ export class FilePreviewScreenComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleAnnotationsAdded(annotations: Annotations.Annotation[]) {
|
handleAnnotationsAdded(annotations: Annotations.Annotation[]) {
|
||||||
// handle comments
|
|
||||||
annotations.forEach((a) => {
|
annotations.forEach((a) => {
|
||||||
a['comments'] = a['Mi']
|
a['comments'] = a['Mi']
|
||||||
? a['Mi'].map((m) => {
|
? a['Mi'].map((m) => {
|
||||||
|
|||||||
@ -15,6 +15,8 @@ import { FileStatus, ManualRedactionEntry, Rectangle } from '@redaction/red-ui-h
|
|||||||
import WebViewer, { Annotations, WebViewerInstance } from '@pdftron/webviewer';
|
import WebViewer, { Annotations, WebViewerInstance } from '@pdftron/webviewer';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { FileDownloadService } from '../service/file-download.service';
|
import { FileDownloadService } from '../service/file-download.service';
|
||||||
|
import { Subject } from 'rxjs';
|
||||||
|
import { throttleTime } from 'rxjs/operators';
|
||||||
|
|
||||||
export interface ViewerState {
|
export interface ViewerState {
|
||||||
displayMode?: any;
|
displayMode?: any;
|
||||||
@ -33,6 +35,7 @@ export interface ViewerState {
|
|||||||
})
|
})
|
||||||
export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges {
|
export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges {
|
||||||
private _viewerState: ViewerState = null; // no initial state
|
private _viewerState: ViewerState = null; // no initial state
|
||||||
|
private _annotationEventDebouncer = new Subject<Annotations.Annotation[]>();
|
||||||
|
|
||||||
@Input() fileData: Blob;
|
@Input() fileData: Blob;
|
||||||
@Input() fileStatus: FileStatus;
|
@Input() fileStatus: FileStatus;
|
||||||
@ -59,6 +62,12 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges {
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this._restoreViewerState = this._restoreViewerState.bind(this);
|
this._restoreViewerState = this._restoreViewerState.bind(this);
|
||||||
|
// always publish all existing annotations this way everything gets drawn always
|
||||||
|
this._annotationEventDebouncer
|
||||||
|
.pipe(throttleTime(300))
|
||||||
|
.subscribe((value) =>
|
||||||
|
this.annotationsAdded.emit(this.instance.annotManager.getAnnotationsList())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges): void {
|
ngOnChanges(changes: SimpleChanges): void {
|
||||||
@ -87,7 +96,7 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges {
|
|||||||
this._configureHeader();
|
this._configureHeader();
|
||||||
instance.annotManager.on('annotationChanged', (annotations, action) => {
|
instance.annotManager.on('annotationChanged', (annotations, action) => {
|
||||||
if (action === 'add') {
|
if (action === 'add') {
|
||||||
this.annotationsAdded.emit(annotations);
|
this._annotationEventDebouncer.next(annotations);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user