Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { PointCloudContainer } from './PointCloudLayout';
import { PointCloudContext } from './PointCloudContext';
import { a2MapStateToProps, IA2MapStateProps } from '@/store/annotation/map';
import { connect } from 'react-redux';
import { jsonParser } from '@/utils';
import { jsonParser, resolveFileItemValid } from '@/utils';
import { useSingleBox } from './hooks/useSingleBox';
import { useSphere } from './hooks/useSphere';
import { Switch, Tooltip } from 'antd';
Expand Down Expand Up @@ -231,9 +231,7 @@ const PointCloud3D: React.FC<IA2MapStateProps> = ({
// Because updatePolygonList will reset the selected state, it is necessary to reset the current rectangle selection
ptCtx.setSelectedIDs(currentSelectInfo.id);
}
const resultObj = jsonParser(currentData.result);
const preResultObj = jsonParser(currentData.preResult);
ptCtx.setPointCloudValid(resultObj?.valid ?? preResultObj?.valid);
ptCtx.setPointCloudValid(resolveFileItemValid(currentData.result, currentData.preResult));
ptCtx.setPointCloudResult(boxParamsList);
ptCtx.setRectList(rectParamsList);
// Update the box of 3D view
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ import { useDispatch, useSelector } from '@/store/ctx';
import { AppState } from '@/store';
import StepUtils from '@/utils/StepUtils';
import { EPointCloudBoxRenderTrigger } from '@/utils/ToolPointCloudBoxRenderHelper';
import { jsonParser, getRectPointCloudBox, generatePointCloudBoxRects } from '@/utils';
import {
jsonParser,
getRectPointCloudBox,
generatePointCloudBoxRects,
resolveFileItemValid,
} from '@/utils';
import type { GeneratePointCloudBoxRectsOptions } from '@/utils';
import {
PreDataProcess,
Expand Down Expand Up @@ -1353,9 +1358,8 @@ export const usePointCloudViews = (params?: IUsePointCloudViewsParams) => {

mainViewInstance.updateTopCamera();

const resultObj = jsonParser(newData.result);
const preResultObj = jsonParser(newData.preResult);
const valid = resultObj?.valid ?? preResultObj?.valid ?? true;

const valid = resolveFileItemValid(newData.result, newData.preResult);
ptCtx.setPointCloudValid(valid);

// Clear other view data during initialization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { DrawLayerSlot } from '@/types/main';
import { PointCloudContext } from './PointCloudContext';
import { EPointCloudPattern, PointCloudUtils } from '@labelbee/lb-utils';
import { useCustomToolInstance } from '@/hooks/annotation';
import { jsonParser } from '@/utils';
import { jsonParser, resolveFileItemValid } from '@/utils';
import { a2MapStateToProps, IA2MapStateProps } from '@/store/annotation/map';
import classNames from 'classnames';
import SideAndBackOverView from './components/sideAndBackOverView';
Expand Down Expand Up @@ -107,6 +107,9 @@ const PointCloudView: React.FC<IProps> = (props) => {
ptCtx.setPointCloudSphereList(sphereParamsList);
ptCtx.setRectList(rectList);
ptCtx.setSegmentation(segmentation);
ptCtx.setPointCloudValid(
resolveFileItemValid(currentData?.result, currentData?.preResult),
);
}
}, [imgIndex]);

Expand Down
4 changes: 2 additions & 2 deletions packages/lb-components/src/store/annotation/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import styleString from '@/constant/styleString';
import { ANNOTATION_ACTIONS } from '@/store/Actions';
import { IFileItem } from '@/types/data';
import { IStepInfo } from '@/types/step';
import { jsonParser } from '@/utils';
import { jsonParser, resolveFileItemValid } from '@/utils';
import AnnotationDataUtils from '@/utils/AnnotationDataUtils';
import { ConfigUtils } from '@/utils/ConfigUtils';
import { composeResult, composeResultWithBasicImgInfo } from '@/utils/data';
Expand Down Expand Up @@ -468,7 +468,7 @@ export const annotationReducer = (

const basicImgInfo = {
rotate: fileResult.rotate ?? 0,
valid: fileResult.valid ?? true,
valid: resolveFileItemValid(imgList[nextIndex]?.result, imgList[nextIndex]?.preResult),
};

if (imgNode && imgError !== true) {
Expand Down
16 changes: 16 additions & 0 deletions packages/lb-components/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@ export const jsonParser = (content: any, defaultValue: any = {}) => {
}
};

/**
* Resolve the effective `valid` flag for a file item.
*
* Priority: result.valid → preResult.valid → true (default)
*
* When a page only has pre-annotation data (result is empty), `result.valid`
* is undefined, so we fall back to `preResult.valid`. A final `?? true`
* prevents passing `undefined` into setPointCloudValid / basicImgInfo.valid,
* which would silently coerce to `true` and override a correct `false` value.
*/
export const resolveFileItemValid = (result?: string, preResult?: string): boolean => {
const resultObj = jsonParser(result);
const preResultObj = jsonParser(preResult);
return resultObj?.valid ?? preResultObj?.valid ?? true;
};

export const getNewNode = <T>(newNode: T, oldNode: T): T => {
return newNode || _.isNull(newNode) ? newNode : oldNode;
};
Expand Down
Loading