fixed delete annotations
This commit is contained in:
parent
101df7f97d
commit
d199af2b39
@ -1,4 +1,4 @@
|
||||
import { ChangeDetectorRef, Component, ElementRef, HostListener, NgZone, OnInit, ViewChild } from '@angular/core';
|
||||
import { ChangeDetectorRef, Component, ElementRef, HostListener, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { AppStateService } from '../../../state/app-state.service';
|
||||
import { WebViewerInstance } from '@pdftron/webviewer';
|
||||
@ -22,6 +22,7 @@ import { NotificationService } from '../../../notification/notification.service'
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { FileStatusWrapper } from '../model/file-status.wrapper';
|
||||
import { PermissionsService } from '../../../common/service/permissions.service';
|
||||
import { Subscription, timer } from 'rxjs';
|
||||
|
||||
const KEY_ARRAY = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'];
|
||||
|
||||
@ -30,7 +31,7 @@ const KEY_ARRAY = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'];
|
||||
templateUrl: './file-preview-screen.component.html',
|
||||
styleUrls: ['./file-preview-screen.component.scss']
|
||||
})
|
||||
export class FilePreviewScreenComponent implements OnInit {
|
||||
export class FilePreviewScreenComponent implements OnInit, OnDestroy {
|
||||
private projectId: string;
|
||||
private _activeViewer: 'ANNOTATED' | 'REDACTED' = 'ANNOTATED';
|
||||
private instance: WebViewerInstance;
|
||||
@ -51,6 +52,7 @@ export class FilePreviewScreenComponent implements OnInit {
|
||||
|
||||
loadingMessage: string;
|
||||
canPerformAnnotationActions: boolean;
|
||||
filesAutoUpdateTimer: Subscription;
|
||||
|
||||
constructor(
|
||||
public readonly appStateService: AppStateService,
|
||||
@ -100,6 +102,13 @@ export class FilePreviewScreenComponent implements OnInit {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.filesAutoUpdateTimer = timer(0, 5000)
|
||||
.pipe(
|
||||
tap(async () => {
|
||||
await this.appStateService.reloadActiveFile();
|
||||
})
|
||||
)
|
||||
.subscribe();
|
||||
this._loadFileData().subscribe(() => {
|
||||
this.canPerformAnnotationActions = this.permissionsService.canPerformAnnotationActions(this.fileData.fileStatus);
|
||||
});
|
||||
@ -116,6 +125,10 @@ export class FilePreviewScreenComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.filesAutoUpdateTimer.unsubscribe();
|
||||
}
|
||||
|
||||
private _loadFileData(performUpdate: boolean = false) {
|
||||
return this._fileDownloadService.loadActiveFileData().pipe(
|
||||
tap((fileDataModel) => {
|
||||
@ -143,7 +156,8 @@ export class FilePreviewScreenComponent implements OnInit {
|
||||
|
||||
private _rebuildFilters(deletePreviousAnnotations: boolean = false) {
|
||||
if (deletePreviousAnnotations) {
|
||||
this.activeViewer.annotManager.deleteAnnotations(this.annotations.map((a) => this.activeViewer.annotManager.getAnnotationById(a.id)));
|
||||
const existingAnnotations = this.annotations.map((a) => this.activeViewer.annotManager.getAnnotationById(a.id));
|
||||
this.activeViewer.annotManager.deleteAnnotations(existingAnnotations, true, true);
|
||||
}
|
||||
this.annotations = this.fileData.getAnnotations(this.appStateService.dictionaryData, this.permissionsService.currentUser);
|
||||
this.filters = this._annotationProcessingService.getAnnotationFilter(this.annotations);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user