file preview screen

This commit is contained in:
Timo Bejan 2022-01-19 08:22:00 +02:00
parent c7ccce829e
commit 9d4aadbfb4

View File

@ -469,23 +469,27 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
const previousFile = this.fileData?.file;
await this._loadFileData(file);
const fileHasBeenExcludedOrIncluded = previousFile?.excluded !== this.fileData?.file?.excluded;
const excludedPagesHaveChanged = JSON.stringify(previousFile?.excludedPages) !== JSON.stringify(this.fileData?.file?.excludedPages);
if (fileHasBeenExcludedOrIncluded || excludedPagesHaveChanged) {
await this._deleteAnnotations();
await this._cleanupAndRedrawAnnotations();
// file already loaded at least once
if (previousFile) {
// If it has been OCRd, we need to wait for it to load into the viewer
if (previousFile.lastOCRTime !== this.fileData?.file?.lastOCRTime) {
return;
}
// excluded pages or document exclusion has changed
const fileHasBeenExcludedOrIncluded = previousFile.excluded !== this.fileData.file.excluded;
const excludedPagesHaveChanged =
JSON.stringify(previousFile.excludedPages) !== JSON.stringify(this.fileData.file.excludedPages);
if (fileHasBeenExcludedOrIncluded || excludedPagesHaveChanged) {
await this._deleteAnnotations();
await this._cleanupAndRedrawAnnotations();
}
}
await this._stampPDF();
}
private async _stampPDF() {
if (!this._instance) {
return;
}
const document = this._instance.Core.documentViewer.getDocument();
if (!document) {
if (!this._instance?.Core.documentViewer.getDocument()) {
return;
}
@ -623,6 +627,10 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
}
private _deleteAnnotations(annotationsToDelete?: AnnotationWrapper[]) {
if (!this._instance?.Core.documentViewer.getDocument()) {
return;
}
if (!annotationsToDelete) {
this._instance.Core.annotationManager.deleteAnnotations(this._instance.Core.annotationManager.getAnnotationsList(), {
imported: true,
@ -638,6 +646,10 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
currentAnnotations?: AnnotationWrapper[],
newAnnotationsFilter?: (annotation: AnnotationWrapper) => boolean,
) {
if (!this._instance?.Core.documentViewer.getDocument()) {
return;
}
this.rebuildFilters();
if (this.viewModeService.viewMode === 'STANDARD') {