Merge branch 'RED-9830' into 'master'

RED-9830: Don't send additional comment request for annotation edit

Closes RED-9830

See merge request redactmanager/red-ui!577
This commit is contained in:
Valentin-Gabriel Mihai 2024-09-23 12:26:04 +02:00
commit 79fb9bd785

View File

@ -1,6 +1,6 @@
import { inject, Injectable } from '@angular/core';
import { Injectable } from '@angular/core';
import { IqserDialog } from '@common-ui/dialog/iqser-dialog.service';
import { getConfig, Toaster } from '@iqser/common-ui';
import { getConfig } from '@iqser/common-ui';
import { List, log } from '@iqser/common-ui/lib/utils';
import { AnnotationPermissions } from '@models/file/annotation.permissions';
import { AnnotationWrapper } from '@models/file/annotation.wrapper';
@ -13,7 +13,6 @@ import {
IRectangle,
IResizeRequest,
} from '@red/domain';
import { CommentsApiService } from '@services/comments-api.service';
import { DossierTemplatesService } from '@services/dossier-templates/dossier-templates.service';
import { PermissionsService } from '@services/permissions.service';
import { firstValueFrom, Observable } from 'rxjs';
@ -48,7 +47,6 @@ import { SkippedService } from './skipped.service';
@Injectable()
export class AnnotationActionsService {
readonly #isDocumine = getConfig().IS_DOCUMINE;
readonly #commentsApiService = inject(CommentsApiService);
constructor(
private readonly _manualRedactionService: ManualRedactionService,
@ -63,7 +61,6 @@ export class AnnotationActionsService {
private readonly _skippedService: SkippedService,
private readonly _dossierTemplatesService: DossierTemplatesService,
private readonly _permissionsService: PermissionsService,
private readonly _toaster: Toaster,
) {}
removeHighlights(highlights: AnnotationWrapper[]): void {
@ -107,7 +104,11 @@ export class AnnotationActionsService {
}
const recategorizeBody: List<IRecategorizationRequest> = annotations.map(annotation => {
const body = { annotationId: annotation.id, type: result.type ?? annotation.type };
const body: IRecategorizationRequest = {
annotationId: annotation.id,
type: result.type ?? annotation.type,
comment: result.comment,
};
if (!this.#isDocumine) {
return {
...body,
@ -130,16 +131,6 @@ export class AnnotationActionsService {
)
.pipe(log()),
);
if (result.comment) {
try {
for (const a of annotations) {
await this.#commentsApiService.add(result.comment, a.id, dossierId, fileId);
}
} catch (error) {
this._toaster.rawError(error.error.message);
}
}
}
async removeRedaction(redactions: AnnotationWrapper[], permissions: AnnotationPermissions) {