From 374ad42a97e698cef708b7467503fa680fe92fed Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Thu, 8 Jul 2021 12:49:10 +0300 Subject: [PATCH 1/2] Fixed issue when save filtered object in AAM --- cvat-ui/src/reducers/annotation-reducer.ts | 35 ++++++++++------------ 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/cvat-ui/src/reducers/annotation-reducer.ts b/cvat-ui/src/reducers/annotation-reducer.ts index 45863c67f154..e2e11a4328fc 100644 --- a/cvat-ui/src/reducers/annotation-reducer.ts +++ b/cvat-ui/src/reducers/annotation-reducer.ts @@ -20,6 +20,12 @@ import { Workspace, } from './interfaces'; +function updateActivatedStateID(newStates: any[], prevActivatedStateID: number | null): number | null { + return prevActivatedStateID === null || newStates.some((_state: any) => _state.clientID === prevActivatedStateID) ? + prevActivatedStateID : + null; +} + const defaultState: AnnotationState = { activities: { loads: {}, @@ -252,6 +258,7 @@ export default (state = defaultState, action: AnyAction): AnnotationState => { }; } case AnnotationActionTypes.CHANGE_FRAME_SUCCESS: { + const { activatedStateID } = state.annotations; const { number, data, @@ -265,12 +272,6 @@ export default (state = defaultState, action: AnyAction): AnnotationState => { changeTime, } = action.payload; - const activatedStateID = states - .map((_state: any) => _state.clientID) - .includes(state.annotations.activatedStateID) ? - state.annotations.activatedStateID : - null; - return { ...state, player: { @@ -291,7 +292,7 @@ export default (state = defaultState, action: AnyAction): AnnotationState => { }, annotations: { ...state.annotations, - activatedStateID, + activatedStateID: updateActivatedStateID(states, activatedStateID), states, zLayer: { min: minZ, @@ -343,11 +344,14 @@ export default (state = defaultState, action: AnyAction): AnnotationState => { } case AnnotationActionTypes.SAVE_ANNOTATIONS_SUCCESS: { const { states } = action.payload; + const { activatedStateID } = state.annotations; + return { ...state, annotations: { ...state.annotations, states, + activatedStateID: updateActivatedStateID(states, activatedStateID), saving: { ...state.annotations.saving, uploading: false, @@ -964,21 +968,16 @@ export default (state = defaultState, action: AnyAction): AnnotationState => { } case AnnotationActionTypes.REDO_ACTION_SUCCESS: case AnnotationActionTypes.UNDO_ACTION_SUCCESS: { + const { activatedStateID } = state.annotations; const { history, states, minZ, maxZ, } = action.payload; - const activatedStateID = states - .map((_state: any) => _state.clientID) - .includes(state.annotations.activatedStateID) ? - state.annotations.activatedStateID : - null; - return { ...state, annotations: { ...state.annotations, - activatedStateID, + activatedStateID: updateActivatedStateID(states, activatedStateID), states, history, zLayer: { @@ -990,18 +989,14 @@ export default (state = defaultState, action: AnyAction): AnnotationState => { }; } case AnnotationActionTypes.FETCH_ANNOTATIONS_SUCCESS: { + const { activatedStateID } = state.annotations; const { states, minZ, maxZ } = action.payload; - const activatedStateID = states - .map((_state: any) => _state.clientID) - .includes(state.annotations.activatedStateID) ? - state.annotations.activatedStateID : - null; return { ...state, annotations: { ...state.annotations, - activatedStateID, + activatedStateID: updateActivatedStateID(states, activatedStateID), states, zLayer: { min: minZ, From d2c4c88a9217977135d210fbe984438111f9d376 Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Thu, 8 Jul 2021 12:53:47 +0300 Subject: [PATCH 2/2] Updated version & changelog --- CHANGELOG.md | 1 + cvat-ui/package-lock.json | 2 +- cvat-ui/package.json | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1af1255db815..bf1521c2a6b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Calculate precise progress of decoding a video file () - Falsely successful `cvat_ui` image build in case of OOM error that leads to the default nginx welcome page () +- Fixed issue when save filtered object in AAM () ### Security diff --git a/cvat-ui/package-lock.json b/cvat-ui/package-lock.json index 8df2dcbb3ed7..3e5119d2b9e2 100644 --- a/cvat-ui/package-lock.json +++ b/cvat-ui/package-lock.json @@ -1,6 +1,6 @@ { "name": "cvat-ui", - "version": "1.20.6", + "version": "1.20.7", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/cvat-ui/package.json b/cvat-ui/package.json index 12d141fd8c6e..38ab13b81f29 100644 --- a/cvat-ui/package.json +++ b/cvat-ui/package.json @@ -1,6 +1,6 @@ { "name": "cvat-ui", - "version": "1.20.6", + "version": "1.20.7", "description": "CVAT single-page application", "main": "src/index.tsx", "scripts": {