diff --git a/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts b/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts index f3a725067..80e5577f9 100644 --- a/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts @@ -17,8 +17,6 @@ import { AutoUnsubscribe, bool, CircleButtonTypes, - ConfirmationDialogInput, - ConfirmOptions, CustomError, Debounce, ErrorService, @@ -26,6 +24,7 @@ import { HelpModeService, List, LoadingService, + log, NestedFilter, OnAttach, OnDetach, @@ -90,7 +89,10 @@ export class FilePreviewScreenComponent fullScreen = false; readonly fileId = this.state.fileId; readonly dossierId = this.state.dossierId; - readonly file$ = this.state.file$.pipe(tap(file => this._fileDataService.loadAnnotations(file))); + readonly file$ = this.state.file$.pipe( + tap(file => this._fileDataService.loadAnnotations(file)), + log('file'), + ); width: number; @ViewChild('annotationFilterTemplate', { read: TemplateRef, diff --git a/apps/red-ui/src/app/modules/file-preview/services/file-data.service.ts b/apps/red-ui/src/app/modules/file-preview/services/file-data.service.ts index 0ed61a9d3..984735983 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/file-data.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/file-data.service.ts @@ -6,7 +6,6 @@ import { Injectable } from '@angular/core'; import { FilePreviewStateService } from './file-preview-state.service'; import { ViewedPagesService } from '@services/files/viewed-pages.service'; import { UserPreferenceService } from '@users/user-preference.service'; -import { DictionariesMapService } from '@services/entity-services/dictionaries-map.service'; import { map, switchMap, tap, withLatestFrom } from 'rxjs/operators'; import { PermissionsService } from '@services/permissions.service'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; @@ -19,7 +18,7 @@ import { NGXLogger } from 'ngx-logger'; import { MultiSelectService } from './multi-select.service'; import { FilesService } from '@services/files/files.service'; import { DefaultColorsService } from '@services/entity-services/default-colors.service'; -import { DossierDictionariesMapService } from '@services/entity-services/dossier-dictionaries-map.service'; +import { DictionaryService } from '@services/entity-services/dictionary.service'; const DELTA_VIEW_TIME = 10 * 60 * 1000; // 10 minutes; @@ -39,8 +38,7 @@ export class FileDataService extends EntitiesService this.#buildAnnotations(redactionLog, file)), + withLatestFrom(this._state.file$), + switchMap(([redactionLog, file]) => this.#buildAnnotations(redactionLog, file)), tap(() => this.#checkMissingTypes()), map(annotations => this._userPreferenceService.areDevFeaturesEnabled ? annotations : annotations.filter(a => !a.isFalsePositive), @@ -172,8 +166,8 @@ export class FileDataService extends EntitiesService AnnotationWrapper.fromData(entry, this._state.dictionaries, this._defaultColorsService.find(this._state.dossierTemplateId)), ); @@ -181,20 +175,28 @@ export class FileDataService extends EntitiesService ann.manual || !file.excludedPages.includes(ann.pageNumber)); } - #convertData(redactionLog: IRedactionLog, file: File): RedactionLogEntry[] { + async #convertData(redactionLog: IRedactionLog, file: File) { const result: RedactionLogEntry[] = []; const sourceIdAnnotationIds: { [key: string]: RedactionLogEntry[] } = {}; + let checkDictionary = true; - redactionLog.redactionLogEntry?.forEach(redactionLogEntry => { + for (const redactionLogEntry of redactionLog.redactionLogEntry) { const changeLogValues = this.#getChangeLogValues(redactionLogEntry, file); if (changeLogValues.hidden) { - return; + continue; + } + + let dictionary = this._state.dictionaries.find(dict => dict.type === redactionLogEntry.type); + if (!dictionary && checkDictionary) { + const dictionaryRequest = this._dictionaryService.loadDictionaryDataForDossierTemplate(this._state.dossierTemplateId); + await firstValueFrom(dictionaryRequest); + checkDictionary = false; + dictionary = this._state.dictionaries.find(dict => dict.type === redactionLogEntry.type); } - const dictionary = this._state.dictionaries.find(dict => dict.type === redactionLogEntry.type); if (!dictionary) { this.missingTypes.add(redactionLogEntry.type); - return; + continue; } const redactionLogEntryWrapper: RedactionLogEntry = new RedactionLogEntry( @@ -213,7 +215,7 @@ export class FileDataService extends EntitiesService !sourceKeys.includes(r.id)); diff --git a/libs/common-ui b/libs/common-ui index c744c7384..c2aa517cb 160000 --- a/libs/common-ui +++ b/libs/common-ui @@ -1 +1 @@ -Subproject commit c744c738451af53ca665b97cc99534bede42a7d4 +Subproject commit c2aa517cb7e92b989355a69de26fe50084a66301