Skip to content

Commit 3eeb18a

Browse files
committed
fix(octra): saving inserted boundaries in transcr-window does not work
1 parent ac19481 commit 3eeb18a

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

apps/octra/src/app/core/store/login-mode/annotation/annotation.reducer.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ export class AnnotationStateReducers {
194194
AnnotationActions.combinePhrases.success,
195195
(state: AnnotationState, { transcript, mode }) => {
196196
if (this.mode === mode) {
197-
state.transcript = transcript;
197+
state.transcript = transcript;
198198
}
199199

200200
return state;
@@ -286,9 +286,23 @@ export class AnnotationStateReducers {
286286

287287
if (currentLevel) {
288288
for (const item of items) {
289-
state.transcript = state.transcript
290-
.clone()
291-
.changeCurrentItemById(item.id, item);
289+
const index = state.transcript.currentLevel?.items.findIndex(
290+
(a) => a.id === item.id
291+
);
292+
if (index !== undefined && index > -1) {
293+
state.transcript = state.transcript
294+
.clone()
295+
.changeCurrentItemByIndex(index, item);
296+
} else {
297+
// add item
298+
state.transcript = state.transcript
299+
.clone()
300+
.addItemToCurrentLevel(
301+
(item as any).time,
302+
item.labels,
303+
(item as any).context
304+
);
305+
}
292306
}
293307
}
294308
}

apps/octra/src/app/editors/2D-editor/transcr-window/transcr-window.component.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ export class TranscrWindowComponent
398398
ngOnInit() {
399399
if (this.currentLevel) {
400400
this.tempSegments = [
401-
...(this.currentLevel.items as OctraAnnotationSegment[]),
401+
...(this.currentLevel.clone().items as OctraAnnotationSegment[]),
402402
];
403403
this.idCounter =
404404
this.annotationStoreService.transcript?.idCounters.item ?? 1;
@@ -629,6 +629,8 @@ export class TranscrWindowComponent
629629
this.annotationStoreService.changeCurrentLevelItems([seg]);
630630
}
631631
}
632+
} else {
633+
this.annotationStoreService.changeCurrentLevelItems(this.tempSegments);
632634
}
633635
}
634636
}
@@ -1199,11 +1201,12 @@ export class TranscrWindowComponent
11991201

12001202
// shift rest of text to next segment
12011203
if (this.tempSegments[segStart + segTexts.length - 1]) {
1202-
(this.tempSegments[
1204+
this.tempSegments[segStart + segTexts.length - 1] = (this.tempSegments[
1205+
segStart + segTexts.length - 1
1206+
] as OctraAnnotationSegment)!.clone();
1207+
this.tempSegments[
12031208
segStart + segTexts.length - 1
1204-
] as OctraAnnotationSegment)!
1205-
.clone()
1206-
.changeFirstLabelWithoutName('Speaker', segTexts[segTexts.length - 1]);
1209+
].changeFirstLabelWithoutName('Speaker', segTexts[segTexts.length - 1]);
12071210
}
12081211
}
12091212

0 commit comments

Comments
 (0)