Skip to content

Commit

Permalink
fix(app): Filter pipette offset calibrations by mount as well (#7017)
Browse files Browse the repository at this point in the history
  • Loading branch information
Laura-Danielle authored Nov 17, 2020
1 parent 3ffad55 commit 8bf5a71
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ describe('getCalibrationForPipette', () => {
Selectors.getCalibrationForPipette(
mockState,
'robot-name',
'P1KVS2108052020A02'
'P1KVS2108052020A02',
'right'
)
).toEqual(Fixtures.mockPipetteOffsetCalibration3)
})
Expand All @@ -48,7 +49,8 @@ describe('getCalibrationForPipette', () => {
Selectors.getCalibrationForPipette(
mockState,
'robot-name',
'no such pipette'
'no such pipette',
'some mount'
)
).toBeNull()
})
Expand All @@ -57,7 +59,8 @@ describe('getCalibrationForPipette', () => {
Selectors.getCalibrationForPipette(
mockState,
'some other robot',
'P20MV2008052020A02'
'P20MV2008052020A02',
'right'
)
).toBeNull()
})
Expand Down
25 changes: 19 additions & 6 deletions app/src/calibration/pipette-offset/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,28 @@ export const getPipetteOffsetCalibrations: (
export const getCalibrationForPipette: (
state: State,
robotName: string,
pipetteSerial: string
) => PipetteOffsetCalibration | null = (state, robotName, pipetteSerial) => {
pipetteSerial: string,
mount: string | null
) => PipetteOffsetCalibration | null = (
state,
robotName,
pipetteSerial,
mount
) => {
const allCalibrations = getPipetteOffsetCalibrations(state, robotName)
return filterCalibrationForPipette(allCalibrations, pipetteSerial)
return filterCalibrationForPipette(allCalibrations, pipetteSerial, mount)
}

export const filterCalibrationForPipette: (
calibrations: Array<PipetteOffsetCalibration>,
pipetteSerial: string
) => PipetteOffsetCalibration | null = (calibrations, pipetteSerial) => {
return head(calibrations.filter(cal => cal.pipette === pipetteSerial)) || null
pipetteSerial: string,
mount: string | null
) => PipetteOffsetCalibration | null = (calibrations, pipetteSerial, mount) => {
return (
head(
calibrations.filter(
cal => cal.pipette === pipetteSerial && cal.mount === mount
)
) || null
)
}
2 changes: 1 addition & 1 deletion app/src/components/ChangePipette/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export function ChangePipette(props: Props): React.Node {
const actualPipette = attachedPipette?.modelSpecs || null
const actualPipetteOffset = useSelector((state: State) =>
attachedPipette?.id
? getCalibrationForPipette(state, robotName, attachedPipette.id)
? getCalibrationForPipette(state, robotName, attachedPipette.id, mount)
: null
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export function PipetteCalibrationInfo(props: Props): React.Node {
const [pocTargetProps, pocTooltipProps] = useHoverTooltip()
const pipetteOffsetCalibration = useSelector((state: State) =>
serialNumber
? getCalibrationForPipette(state, robotName, serialNumber)
? getCalibrationForPipette(state, robotName, serialNumber, mount)
: null
)
const tipLengthCalibration = useSelector((state: State) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ const mockGetCustomLabwareDefinitions: JestMockFn<
> = getCustomLabwareDefinitions

const mockGetCalibrationForPipette: JestMockFn<
[State, string, string],
$Call<typeof getCalibrationForPipette, State, string, string>
[State, string, string, string],
$Call<typeof getCalibrationForPipette, State, string, string, string>
> = getCalibrationForPipette

const mockGetTipLengthForPipetteAndTiprack: JestMockFn<
Expand Down
7 changes: 6 additions & 1 deletion app/src/pages/Calibrate/Pipettes.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,12 @@ export function Pipettes(props: Props): React.Node {
const convertRobotNameToString = robotName || 'unknown'
const pipetteOffsetCalibration = useSelector((state: State) =>
serialNumber
? getCalibrationForPipette(state, convertRobotNameToString, serialNumber)
? getCalibrationForPipette(
state,
convertRobotNameToString,
serialNumber,
currentMount
)
: null
)

Expand Down
4 changes: 2 additions & 2 deletions app/src/pipettes/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ export const getAttachedPipetteCalibrations: (
(attached, calibrations, tipLengths) => {
const offsets = {
left: attached.left
? filterCalibrationForPipette(calibrations, attached.left.id)
? filterCalibrationForPipette(calibrations, attached.left.id, 'left')
: null,
right: attached.right
? filterCalibrationForPipette(calibrations, attached.right.id)
? filterCalibrationForPipette(calibrations, attached.right.id, 'right')
: null,
}
return {
Expand Down

0 comments on commit 8bf5a71

Please sign in to comment.