fix RED-3108 & RED-3109
This commit is contained in:
parent
4fca8621fa
commit
ecf57233ba
@ -50,6 +50,14 @@ import PDFNet = Core.PDFNet;
|
||||
|
||||
const ALL_HOTKEY_ARRAY = ['Escape', 'F', 'f', 'ArrowUp', 'ArrowDown'];
|
||||
|
||||
function diff<T>(first: readonly T[], second: readonly T[]): T[] {
|
||||
// symmetrical difference between two arrays
|
||||
const a = new Set(first);
|
||||
const b = new Set(second);
|
||||
|
||||
return [...first.filter(x => !b.has(x)), ...second.filter(x => !a.has(x))];
|
||||
}
|
||||
|
||||
@Component({
|
||||
templateUrl: './file-preview-screen.component.html',
|
||||
styleUrls: ['./file-preview-screen.component.scss'],
|
||||
@ -232,8 +240,8 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
console.log(`[REDACTION] Delete previous annotations time: ${new Date().getTime() - startTime} ms`);
|
||||
}
|
||||
console.log(`[REDACTION] Delete previous annotations time: ${new Date().getTime() - startTime} ms`);
|
||||
const processStartTime = new Date().getTime();
|
||||
const dossier = this._dossiersService.find(this.dossierId);
|
||||
const newAnnotationsData = this.fileData.getAnnotations(
|
||||
@ -261,11 +269,8 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
filters: processFilters(secondaryFilters, AnnotationProcessingService.secondaryAnnotationFilters(this.fileData?.viewedPages)),
|
||||
});
|
||||
console.log(`[REDACTION] Process time: ${new Date().getTime() - processStartTime} ms`);
|
||||
console.log(
|
||||
`[REDACTION] Annotation Redraw and filter rebuild time: ${new Date().getTime() - startTime} ms for: ${
|
||||
this.annotations.length
|
||||
} annotations`,
|
||||
);
|
||||
console.log(`[REDACTION] Filter rebuild time: ${new Date().getTime() - startTime}`);
|
||||
console.log();
|
||||
}
|
||||
|
||||
handleAnnotationSelected(annotationIds: string[]) {
|
||||
@ -311,7 +316,6 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
response.manualRedactionEntryWrapper.rectId,
|
||||
);
|
||||
this._instance.Core.annotationManager.deleteAnnotation(annotation);
|
||||
await this._filesService.reload(this.dossierId, this.fileId).toPromise();
|
||||
const distinctPages = manualRedactionEntryWrapper.manualRedactionEntry.positions
|
||||
.map(p => p.page)
|
||||
.filter((item, pos, self) => self.indexOf(item) === pos);
|
||||
@ -469,7 +473,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
}
|
||||
|
||||
private _setHiddenPropertyToNewAnnotations(newAnnotations: AnnotationWrapper[], oldAnnotations: AnnotationWrapper[]) {
|
||||
newAnnotations.map(newAnnotation => {
|
||||
newAnnotations.forEach(newAnnotation => {
|
||||
const oldAnnotation = oldAnnotations.find(a => a.annotationId === newAnnotation.annotationId);
|
||||
if (oldAnnotation) {
|
||||
newAnnotation.hidden = oldAnnotation.hidden;
|
||||
@ -497,7 +501,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
}
|
||||
this._instance.Core.documentViewer.refreshAll();
|
||||
this._instance.Core.documentViewer.updateView([this.activeViewerPage], this.activeViewerPage);
|
||||
this._changeDetectorRef.detectChanges();
|
||||
this._changeDetectorRef.markForCheck();
|
||||
}
|
||||
|
||||
private async _stampPreview(document: PDFNet.PDFDoc, dossierTemplateId: string) {
|
||||
@ -540,8 +544,8 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
.subscribe(async file => {
|
||||
await this._loadFileData(file, !this._reloadFileOnReanalysis);
|
||||
this._reloadFileOnReanalysis = false;
|
||||
this._loadingService.stop();
|
||||
await this._reloadAnnotations();
|
||||
this._loadingService.stop();
|
||||
});
|
||||
}
|
||||
|
||||
@ -552,21 +556,21 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
|
||||
const fileData = await this._fileDownloadService.loadDataFor(file).toPromise();
|
||||
|
||||
if (!file.isPending) {
|
||||
let excludedOrIncludedPages = new Set<number>();
|
||||
let currentPageAnnotations: AnnotationWrapper[] = [];
|
||||
if (file.isPending) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (performUpdate && !!this.fileData) {
|
||||
this.fileData.redactionLog = fileData.redactionLog;
|
||||
this.fileData.viewedPages = fileData.viewedPages;
|
||||
excludedOrIncludedPages = new Set([...this.fileData.file.excludedPages, ...file.excludedPages]);
|
||||
currentPageAnnotations = this.annotations.filter(a => excludedOrIncludedPages.has(a.pageNumber));
|
||||
this.fileData.file = file;
|
||||
} else {
|
||||
this.fileData = fileData;
|
||||
if (performUpdate && !!this.fileData) {
|
||||
this.fileData.redactionLog = fileData.redactionLog;
|
||||
this.fileData.viewedPages = fileData.viewedPages;
|
||||
const excludedOrIncludedPages = new Set(diff(this.fileData.file.excludedPages, file.excludedPages));
|
||||
const currentPageAnnotations = this.annotations.filter(a => excludedOrIncludedPages.has(a.pageNumber));
|
||||
this.fileData.file = file;
|
||||
if (excludedOrIncludedPages?.size) {
|
||||
await this._cleanupAndRedrawAnnotations(currentPageAnnotations, a => excludedOrIncludedPages.has(a.pageNumber));
|
||||
}
|
||||
|
||||
return this._cleanupAndRedrawAnnotations(currentPageAnnotations, a => excludedOrIncludedPages.has(a.pageNumber));
|
||||
} else {
|
||||
this.fileData = fileData;
|
||||
}
|
||||
}
|
||||
|
||||
@ -584,7 +588,6 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
private async _reloadAnnotationsForPage(page: number) {
|
||||
const currentPageAnnotations = this.annotations.filter(a => a.pageNumber === page);
|
||||
|
||||
await this._filesService.reload(this.dossierId, this.fileId).toPromise();
|
||||
this.fileData.redactionLog = await this._fileDownloadService.loadRedactionLogFor(this.dossierId, this.fileId).toPromise();
|
||||
|
||||
await this._cleanupAndRedrawAnnotations(currentPageAnnotations, annotation => annotation.pageNumber === page);
|
||||
@ -597,12 +600,16 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
this.rebuildFilters();
|
||||
|
||||
if (this.viewModeService.viewMode === 'STANDARD') {
|
||||
const startTime = new Date().getTime();
|
||||
annotationsToDelete?.forEach(annotation => {
|
||||
this._findAndDeleteAnnotation(annotation.id);
|
||||
});
|
||||
const newPageAnnotations = newAnnotationsFilter ? this.annotations.filter(newAnnotationsFilter) : this.annotations;
|
||||
this._handleDeltaAnnotationFilters(annotationsToDelete ?? [], newPageAnnotations);
|
||||
await this._redrawAnnotations(newPageAnnotations);
|
||||
const newAnnotations = newAnnotationsFilter ? this.annotations.filter(newAnnotationsFilter) : this.annotations;
|
||||
this._handleDeltaAnnotationFilters(annotationsToDelete ?? [], newAnnotations);
|
||||
await this._redrawAnnotations(newAnnotations);
|
||||
console.log(
|
||||
`[REDACTION] Annotations redraw time: ${new Date().getTime() - startTime} ms for ${newAnnotations.length} annotations`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user