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'];
|
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({
|
@Component({
|
||||||
templateUrl: './file-preview-screen.component.html',
|
templateUrl: './file-preview-screen.component.html',
|
||||||
styleUrls: ['./file-preview-screen.component.scss'],
|
styleUrls: ['./file-preview-screen.component.scss'],
|
||||||
@ -232,8 +240,8 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(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 processStartTime = new Date().getTime();
|
||||||
const dossier = this._dossiersService.find(this.dossierId);
|
const dossier = this._dossiersService.find(this.dossierId);
|
||||||
const newAnnotationsData = this.fileData.getAnnotations(
|
const newAnnotationsData = this.fileData.getAnnotations(
|
||||||
@ -261,11 +269,8 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
|||||||
filters: processFilters(secondaryFilters, AnnotationProcessingService.secondaryAnnotationFilters(this.fileData?.viewedPages)),
|
filters: processFilters(secondaryFilters, AnnotationProcessingService.secondaryAnnotationFilters(this.fileData?.viewedPages)),
|
||||||
});
|
});
|
||||||
console.log(`[REDACTION] Process time: ${new Date().getTime() - processStartTime} ms`);
|
console.log(`[REDACTION] Process time: ${new Date().getTime() - processStartTime} ms`);
|
||||||
console.log(
|
console.log(`[REDACTION] Filter rebuild time: ${new Date().getTime() - startTime}`);
|
||||||
`[REDACTION] Annotation Redraw and filter rebuild time: ${new Date().getTime() - startTime} ms for: ${
|
console.log();
|
||||||
this.annotations.length
|
|
||||||
} annotations`,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handleAnnotationSelected(annotationIds: string[]) {
|
handleAnnotationSelected(annotationIds: string[]) {
|
||||||
@ -311,7 +316,6 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
|||||||
response.manualRedactionEntryWrapper.rectId,
|
response.manualRedactionEntryWrapper.rectId,
|
||||||
);
|
);
|
||||||
this._instance.Core.annotationManager.deleteAnnotation(annotation);
|
this._instance.Core.annotationManager.deleteAnnotation(annotation);
|
||||||
await this._filesService.reload(this.dossierId, this.fileId).toPromise();
|
|
||||||
const distinctPages = manualRedactionEntryWrapper.manualRedactionEntry.positions
|
const distinctPages = manualRedactionEntryWrapper.manualRedactionEntry.positions
|
||||||
.map(p => p.page)
|
.map(p => p.page)
|
||||||
.filter((item, pos, self) => self.indexOf(item) === pos);
|
.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[]) {
|
private _setHiddenPropertyToNewAnnotations(newAnnotations: AnnotationWrapper[], oldAnnotations: AnnotationWrapper[]) {
|
||||||
newAnnotations.map(newAnnotation => {
|
newAnnotations.forEach(newAnnotation => {
|
||||||
const oldAnnotation = oldAnnotations.find(a => a.annotationId === newAnnotation.annotationId);
|
const oldAnnotation = oldAnnotations.find(a => a.annotationId === newAnnotation.annotationId);
|
||||||
if (oldAnnotation) {
|
if (oldAnnotation) {
|
||||||
newAnnotation.hidden = oldAnnotation.hidden;
|
newAnnotation.hidden = oldAnnotation.hidden;
|
||||||
@ -497,7 +501,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
|||||||
}
|
}
|
||||||
this._instance.Core.documentViewer.refreshAll();
|
this._instance.Core.documentViewer.refreshAll();
|
||||||
this._instance.Core.documentViewer.updateView([this.activeViewerPage], this.activeViewerPage);
|
this._instance.Core.documentViewer.updateView([this.activeViewerPage], this.activeViewerPage);
|
||||||
this._changeDetectorRef.detectChanges();
|
this._changeDetectorRef.markForCheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _stampPreview(document: PDFNet.PDFDoc, dossierTemplateId: string) {
|
private async _stampPreview(document: PDFNet.PDFDoc, dossierTemplateId: string) {
|
||||||
@ -540,8 +544,8 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
|||||||
.subscribe(async file => {
|
.subscribe(async file => {
|
||||||
await this._loadFileData(file, !this._reloadFileOnReanalysis);
|
await this._loadFileData(file, !this._reloadFileOnReanalysis);
|
||||||
this._reloadFileOnReanalysis = false;
|
this._reloadFileOnReanalysis = false;
|
||||||
this._loadingService.stop();
|
|
||||||
await this._reloadAnnotations();
|
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();
|
const fileData = await this._fileDownloadService.loadDataFor(file).toPromise();
|
||||||
|
|
||||||
if (!file.isPending) {
|
if (file.isPending) {
|
||||||
let excludedOrIncludedPages = new Set<number>();
|
return;
|
||||||
let currentPageAnnotations: AnnotationWrapper[] = [];
|
}
|
||||||
|
|
||||||
if (performUpdate && !!this.fileData) {
|
if (performUpdate && !!this.fileData) {
|
||||||
this.fileData.redactionLog = fileData.redactionLog;
|
this.fileData.redactionLog = fileData.redactionLog;
|
||||||
this.fileData.viewedPages = fileData.viewedPages;
|
this.fileData.viewedPages = fileData.viewedPages;
|
||||||
excludedOrIncludedPages = new Set([...this.fileData.file.excludedPages, ...file.excludedPages]);
|
const excludedOrIncludedPages = new Set(diff(this.fileData.file.excludedPages, file.excludedPages));
|
||||||
currentPageAnnotations = this.annotations.filter(a => excludedOrIncludedPages.has(a.pageNumber));
|
const currentPageAnnotations = this.annotations.filter(a => excludedOrIncludedPages.has(a.pageNumber));
|
||||||
this.fileData.file = file;
|
this.fileData.file = file;
|
||||||
} else {
|
if (excludedOrIncludedPages?.size) {
|
||||||
this.fileData = fileData;
|
await this._cleanupAndRedrawAnnotations(currentPageAnnotations, a => excludedOrIncludedPages.has(a.pageNumber));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
return this._cleanupAndRedrawAnnotations(currentPageAnnotations, a => excludedOrIncludedPages.has(a.pageNumber));
|
this.fileData = fileData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -584,7 +588,6 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
|||||||
private async _reloadAnnotationsForPage(page: number) {
|
private async _reloadAnnotationsForPage(page: number) {
|
||||||
const currentPageAnnotations = this.annotations.filter(a => a.pageNumber === page);
|
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();
|
this.fileData.redactionLog = await this._fileDownloadService.loadRedactionLogFor(this.dossierId, this.fileId).toPromise();
|
||||||
|
|
||||||
await this._cleanupAndRedrawAnnotations(currentPageAnnotations, annotation => annotation.pageNumber === page);
|
await this._cleanupAndRedrawAnnotations(currentPageAnnotations, annotation => annotation.pageNumber === page);
|
||||||
@ -597,12 +600,16 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
|||||||
this.rebuildFilters();
|
this.rebuildFilters();
|
||||||
|
|
||||||
if (this.viewModeService.viewMode === 'STANDARD') {
|
if (this.viewModeService.viewMode === 'STANDARD') {
|
||||||
|
const startTime = new Date().getTime();
|
||||||
annotationsToDelete?.forEach(annotation => {
|
annotationsToDelete?.forEach(annotation => {
|
||||||
this._findAndDeleteAnnotation(annotation.id);
|
this._findAndDeleteAnnotation(annotation.id);
|
||||||
});
|
});
|
||||||
const newPageAnnotations = newAnnotationsFilter ? this.annotations.filter(newAnnotationsFilter) : this.annotations;
|
const newAnnotations = newAnnotationsFilter ? this.annotations.filter(newAnnotationsFilter) : this.annotations;
|
||||||
this._handleDeltaAnnotationFilters(annotationsToDelete ?? [], newPageAnnotations);
|
this._handleDeltaAnnotationFilters(annotationsToDelete ?? [], newAnnotations);
|
||||||
await this._redrawAnnotations(newPageAnnotations);
|
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