RED-6466: mark annotation as redaction if re-created
This commit is contained in:
parent
c64d787e7f
commit
9903c808fa
@ -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<string, unknown> {
|
||||
[x: string]: unknown;
|
||||
@ -356,6 +358,15 @@ export class AnnotationWrapper implements IListable, Record<string, unknown> {
|
||||
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;
|
||||
|
||||
|
||||
@ -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<T>(property: (x: T) => string) {
|
||||
export function chronologicallyBy<T>(property: (x: T) => string) {
|
||||
return (a: T, b: T) => timestampOf(property(a)) - timestampOf(property(b));
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user