diff --git a/apps/red-ui/src/app/models/file/annotation.wrapper.ts b/apps/red-ui/src/app/models/file/annotation.wrapper.ts index eb1104ca8..d56050efa 100644 --- a/apps/red-ui/src/app/models/file/annotation.wrapper.ts +++ b/apps/red-ui/src/app/models/file/annotation.wrapper.ts @@ -4,6 +4,7 @@ import { annotationDefaultColorConfig, annotationEntityColorConfig, AnnotationIconType, + ChangeTypes, DefaultColors, Dictionary, Earmark, @@ -23,6 +24,7 @@ import { } from '@red/domain'; import { RedactionLogEntry } from '@models/file/redaction-log.entry'; import { IListable, List } from '@iqser/common-ui'; +import { chronologicallyBy, timestampOf } from '../../modules/file-preview/services/file-data.service'; export class AnnotationWrapper implements IListable, Record { [x: string]: unknown; @@ -356,6 +358,15 @@ export class AnnotationWrapper implements IListable, Record { private static _setSuperType(annotationWrapper: AnnotationWrapper, redactionLogEntryWrapper: RedactionLogEntry) { if (redactionLogEntryWrapper.manualChanges?.length) { const lastRelevantManualChange = this._getLastRelevantManualChange(redactionLogEntryWrapper.manualChanges); + const viableChanges = redactionLogEntryWrapper.changes.filter(c => c.analysisNumber > 1); + const lastChange = viableChanges.sort(chronologicallyBy(x => x.dateTime)).at(-1); + const lastChangeOccurredAfterLastManualChange = + timestampOf(lastChange.dateTime) > timestampOf(lastRelevantManualChange.processedDate); + + if (lastChangeOccurredAfterLastManualChange && lastChange.type === ChangeTypes.ADDED && redactionLogEntryWrapper.redacted) { + annotationWrapper.superType = SuperTypes.Redaction; + return; + } annotationWrapper.pending = !lastRelevantManualChange.processed; 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 0a7402161..6197b6cba 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 @@ -34,11 +34,11 @@ import { ViewedPagesMapService } from '@services/files/viewed-pages-map.service' const DELTA_VIEW_TIME = 10 * 60 * 1000; // 10 minutes; -function timestampOf(value: string) { +export function timestampOf(value: string) { return dayjs(value).valueOf(); } -function chronologicallyBy(property: (x: T) => string) { +export function chronologicallyBy(property: (x: T) => string) { return (a: T, b: T) => timestampOf(property(a)) - timestampOf(property(b)); }