diff --git a/CHANGELOG.md b/CHANGELOG.md index bf1521c2a6b46abc6789c7c97227ff3bb9f799ed..21985e2e8ace3de53e16cf956685af19ecde8450 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - 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 () +- Context image disappears after undo/redo () ### Security diff --git a/cvat-ui/src/actions/annotation-actions.ts b/cvat-ui/src/actions/annotation-actions.ts index 800e3009048647cbdafbdabb2335541021b3c9d1..9a3c866ef36c75e54ef2aa32a4a70b574385d852 100644 --- a/cvat-ui/src/actions/annotation-actions.ts +++ b/cvat-ui/src/actions/annotation-actions.ts @@ -801,7 +801,6 @@ export function undoActionAsync(sessionInstance: any, frame: number): ThunkActio true, ); - dispatch(changeFrameAsync(undo[1])); await sessionInstance.actions.undo(); const history = await sessionInstance.actions.get(); const states = await sessionInstance.annotations.get(frame, showAllInterpolationTracks, filters); @@ -817,6 +816,11 @@ export function undoActionAsync(sessionInstance: any, frame: number): ThunkActio maxZ, }, }); + + const undoOnFrame = undo[1]; + if (frame !== undoOnFrame) { + dispatch(changeFrameAsync(undoOnFrame)); + } } catch (error) { dispatch({ type: AnnotationActionTypes.UNDO_ACTION_FAILED, @@ -845,7 +849,7 @@ export function redoActionAsync(sessionInstance: any, frame: number): ThunkActio }, true, ); - dispatch(changeFrameAsync(redo[1])); + await sessionInstance.actions.redo(); const history = await sessionInstance.actions.get(); const states = await sessionInstance.annotations.get(frame, showAllInterpolationTracks, filters); @@ -861,6 +865,11 @@ export function redoActionAsync(sessionInstance: any, frame: number): ThunkActio maxZ, }, }); + + const redoOnFrame = redo[1]; + if (frame !== redoOnFrame) { + dispatch(changeFrameAsync(redoOnFrame)); + } } catch (error) { dispatch({ type: AnnotationActionTypes.REDO_ACTION_FAILED, @@ -1632,7 +1641,7 @@ export function hideShowContextImage(hidden: boolean): AnyAction { }; } -export function getContextImage(): ThunkAction { +export function getContextImageAsync(): ThunkAction { return async (dispatch: ActionCreator): Promise => { const state: CombinedState = getStore().getState(); const { instance: job } = state.annotation.job; diff --git a/cvat-ui/src/components/annotation-page/standard-workspace/context-image/context-image.tsx b/cvat-ui/src/components/annotation-page/standard-workspace/context-image/context-image.tsx index 803674af50e7a50ba2d6976ecc646263c8d2ed6e..b2ab80c0002528b27dafee462c6be724e60cf738 100644 --- a/cvat-ui/src/components/annotation-page/standard-workspace/context-image/context-image.tsx +++ b/cvat-ui/src/components/annotation-page/standard-workspace/context-image/context-image.tsx @@ -10,7 +10,7 @@ import Spin from 'antd/lib/spin'; import Image from 'antd/lib/image'; import { CombinedState } from 'reducers/interfaces'; -import { hideShowContextImage, getContextImage } from 'actions/annotation-actions'; +import { hideShowContextImage, getContextImageAsync } from 'actions/annotation-actions'; import CVATTooltip from 'components/common/cvat-tooltip'; export function adjustContextImagePosition(sidebarCollapsed: boolean): void { @@ -26,7 +26,7 @@ export function adjustContextImagePosition(sidebarCollapsed: boolean): void { } } -export default function ContextImage(): JSX.Element | null { +function ContextImage(): JSX.Element | null { const dispatch = useDispatch(); const { number: frame, hasRelatedContext } = useSelector((state: CombinedState) => state.annotation.player.frame); const { data: contextImageData, hidden: contextImageHidden, fetching: contextImageFetching } = useSelector( @@ -42,7 +42,7 @@ export default function ContextImage(): JSX.Element | null { useEffect(() => { if (hasRelatedContext && !contextImageHidden && !requested) { - dispatch(getContextImage()); + dispatch(getContextImageAsync()); setRequested(true); } }, [contextImageHidden, requested, hasRelatedContext]); @@ -85,3 +85,5 @@ export default function ContextImage(): JSX.Element | null { ); } + +export default React.memo(ContextImage); diff --git a/cvat-ui/src/reducers/annotation-reducer.ts b/cvat-ui/src/reducers/annotation-reducer.ts index e2e11a4328fcb995604b06bd870a1ba9c0cf9fd2..eb71b8fa16f0a8a626d0f57cf38835512700c351 100644 --- a/cvat-ui/src/reducers/annotation-reducer.ts +++ b/cvat-ui/src/reducers/annotation-reducer.ts @@ -287,7 +287,7 @@ export default (state = defaultState, action: AnyAction): AnnotationState => { }, contextImage: { ...state.player.contextImage, - data: null, + ...(state.player.frame.number === number ? {} : { data: null }), }, }, annotations: {