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 ef04cce80..975f77543 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 @@ -179,17 +179,19 @@ export class FileDataService extends EntitiesService { - const redactionLogCopy = JSON.parse(JSON.stringify(redactionLog)); - redactionLogCopy.redactionLogEntry = redactionLogCopy.redactionLogEntry.reduce((filtered, entry) => { - const lastChange = entry.manualChanges.at(-1); - const isRemoveChange = this.#isRemoveChange(lastChange?.manualRedactionType); - if (isRemoveChange) { - entry.manualChanges.pop(); - filtered.push(entry); - } - return filtered; - }, []); - this._suggestionsService.removedRedactions = await this.#buildAnnotations(redactionLogCopy, file); + if (redactionLog.redactionLogEntry) { + const redactionLogCopy = JSON.parse(JSON.stringify(redactionLog)); + redactionLogCopy.redactionLogEntry = redactionLogCopy.redactionLogEntry?.reduce((filtered, entry) => { + const lastChange = entry.manualChanges.at(-1); + const isRemoveChange = this.#isRemoveChange(lastChange?.manualRedactionType); + if (isRemoveChange) { + entry.manualChanges.pop(); + filtered.push(entry); + } + return filtered; + }, []); + this._suggestionsService.removedRedactions = await this.#buildAnnotations(redactionLogCopy, file); + } } #isRemoveChange(type: ManualRedactionType) { @@ -201,41 +203,43 @@ export class FileDataService extends EntitiesService 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); - } - - if (!dictionary) { - this.missingTypes.add(redactionLogEntry.type); - continue; - } - - const redactionLogEntryWrapper: RedactionLogEntry = new RedactionLogEntry( - redactionLogEntry, - changeLogValues.changeLogType, - changeLogValues.isChangeLogEntry, - redactionLog.legalBasis, - !!dictionary?.hint, - ); - - if (redactionLogEntry.sourceId) { - if (!sourceIdAnnotationIds[redactionLogEntry.sourceId]) { - sourceIdAnnotationIds[redactionLogEntry.sourceId] = []; + if (redactionLog.redactionLogEntry) { + for (const redactionLogEntry of redactionLog.redactionLogEntry) { + const changeLogValues = this.#getChangeLogValues(redactionLogEntry, file); + if (changeLogValues.hidden) { + continue; } - sourceIdAnnotationIds[redactionLogEntry.sourceId].push(redactionLogEntryWrapper); - } - result.push(redactionLogEntryWrapper); + 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); + } + + if (!dictionary) { + this.missingTypes.add(redactionLogEntry.type); + continue; + } + + const redactionLogEntryWrapper: RedactionLogEntry = new RedactionLogEntry( + redactionLogEntry, + changeLogValues.changeLogType, + changeLogValues.isChangeLogEntry, + redactionLog.legalBasis, + !!dictionary?.hint, + ); + + if (redactionLogEntry.sourceId) { + if (!sourceIdAnnotationIds[redactionLogEntry.sourceId]) { + sourceIdAnnotationIds[redactionLogEntry.sourceId] = []; + } + sourceIdAnnotationIds[redactionLogEntry.sourceId].push(redactionLogEntryWrapper); + } + + result.push(redactionLogEntryWrapper); + } } const sourceKeys = Object.keys(sourceIdAnnotationIds);