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