Skip to content
This repository was archived by the owner on Jan 19, 2025. It is now read-only.

Commit 04a8114

Browse files
authored
feat(gui): improve annotation merging (#816)
* feat(gui): merge pure annotations * feat(gui): merge remove annotations * feat(gui): merge calledAfter annotations * feat(gui): merge complete annotations * test(gui): additional merging tests * test(gui): more failing tests * feat(gui): get these tests working * refactor(gui): reduce duplication * feat(gui): merge group annotations * refactor(gui): rename variable * test(gui): additional merging tests * feat(gui): get some tests passing * feat(gui): get all tests passing * style: apply automatic fixes of linters Co-authored-by: lars-reimann <[email protected]>
1 parent ef44f49 commit 04a8114

File tree

3 files changed

+4235
-21
lines changed

3 files changed

+4235
-21
lines changed

api-editor/gui/src/features/annotations/annotationSlice.ts

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { createAsyncThunk, createSlice, PayloadAction } from '@reduxjs/toolkit';
22
import * as idb from 'idb-keyval';
33
import { RootState } from '../../app/store';
44
import { isValidUsername } from '../../common/util/validation';
5+
import { mergeAnnotationStores } from './mergeAnnotationStores';
56

67
export const EXPECTED_ANNOTATION_STORE_SCHEMA_VERSION = 1;
78
export const EXPECTED_ANNOTATION_SLICE_SCHEMA_VERSION = 1;
@@ -383,27 +384,7 @@ const annotationsSlice = createSlice({
383384
updateQueue(state);
384385
},
385386
mergeAnnotationStore(state, action: PayloadAction<AnnotationStore>) {
386-
for (const annotationType of Object.keys(action.payload)) {
387-
if (annotationType === 'calledAfters' || annotationType === 'groups') {
388-
for (const target of Object.keys(action.payload[annotationType])) {
389-
// @ts-ignore
390-
state.annotations[annotationType][target] = {
391-
// @ts-ignore
392-
...(state.annotations[annotationType][target] ?? {}),
393-
// @ts-ignore
394-
...action.payload[annotationType][target],
395-
};
396-
}
397-
} else {
398-
// @ts-ignore
399-
state.annotations[annotationType] = {
400-
// @ts-ignore
401-
...state.annotations[annotationType],
402-
// @ts-ignore
403-
...action.payload[annotationType],
404-
};
405-
}
406-
}
387+
state.annotations = mergeAnnotationStores(state.annotations, action.payload);
407388

408389
updateQueue(state);
409390
},

0 commit comments

Comments
 (0)