Skip to content

Commit

Permalink
ISSUE #5173 - fix: calibration can be partial
Browse files Browse the repository at this point in the history
  • Loading branch information
Amantini1997 committed Sep 27, 2024
1 parent f0c4b7c commit ae145d3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
2 changes: 1 addition & 1 deletion frontend/src/v5/store/drawings/drawings.helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export const fullDrawing = (
const status = drawing.status ?? UploadStatus.OK;
const isFavourite = drawing.isFavourite ?? false;
const role = drawing.role ?? Role.ADMIN;
const calibration = drawing.calibration || EMPTY_CALIBRATION;
const calibration = { ...EMPTY_CALIBRATION, ...drawing.calibration };

return {
...drawing,
Expand Down
9 changes: 2 additions & 7 deletions frontend/src/v5/store/drawings/drawings.selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { isEqual, orderBy } from 'lodash';
import { Vector2 } from 'three';
import { fullDrawing } from './drawings.helpers';
import { selectRevisionsByDrawing } from './revisions/drawingRevisions.selectors';
import { Calibration, CalibrationStatus } from './drawings.types';
import { Calibration } from './drawings.types';

const selectDrawingsDomain = (state): DrawingsState => state?.drawings || ({ drawingsByProjectByProject: {} });

Expand Down Expand Up @@ -58,11 +58,6 @@ export const selectDrawingById = createSelector(
(drawings, _id) => drawings.find((d) => d._id === _id),
);

export const selectDrawingCalibration = createSelector(
selectDrawingById,
(drawing) => drawing.calibrationStatus ?? CalibrationStatus.EMPTY,
);

export const selectIsListPending = createSelector(
selectDrawingsDomain, selectCurrentProject,
// Checks if the drawings for the project have been fetched
Expand Down Expand Up @@ -105,7 +100,7 @@ export const selectCalibration = createSelector(
selectDrawingById,
(state, drawingId, modelId) => selectContainerById(state, modelId) || selectFederationById(state, modelId),
(drawing, model) => {
const calibration = drawing?.calibration || EMPTY_CALIBRATION;
const calibration = { ...EMPTY_CALIBRATION, ...drawing?.calibration };
const conversionFactor = getUnitsConversionFactor(calibration.units, model.unit);
const horizontalCalibration = calibration.horizontal;

Expand Down

0 comments on commit ae145d3

Please sign in to comment.