-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(app): fix fetch-on-session-end epics for POC, TLC (#6757)
The epics to fetch pipette offset calibration and tip length calibration were using the wrong rxjs operators to emit their actions, and consequently would fire at the right times but not actually incur a fetch from the robot. In addition, the UI works much better if the data is fetched when the session delete _starts_ rather than completes successfully, since most session wizards go away when the delete begins and therefore let the user see the places where the data goes. Closes #6747 Co-authored-by: ahiuchingau <[email protected]>
- Loading branch information
1 parent
00fe420
commit 7124bd9
Showing
4 changed files
with
180 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 30 additions & 12 deletions
42
app/src/calibration/pipette-offset/epic/fetchPipetteOffsetCalibrationsOnCalibrationEnd.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,62 @@ | ||
// @flow | ||
|
||
import { of } from 'rxjs' | ||
import { filter, withLatestFrom, mergeMap } from 'rxjs/operators' | ||
import { filter, withLatestFrom, map } from 'rxjs/operators' | ||
import { ofType } from 'redux-observable' | ||
|
||
import { getConnectedRobotName } from '../../../robot/selectors' | ||
import * as Actions from '../actions' | ||
import type { Epic } from '../../../types' | ||
import type { Epic, State } from '../../../types' | ||
|
||
import type { SessionType } from '../../../sessions/types' | ||
import { | ||
DELETE_SESSION_SUCCESS, | ||
DELETE_SESSION, | ||
SESSION_TYPE_CALIBRATION_CHECK, | ||
SESSION_TYPE_TIP_LENGTH_CALIBRATION, | ||
SESSION_TYPE_DECK_CALIBRATION, | ||
SESSION_TYPE_PIPETTE_OFFSET_CALIBRATION, | ||
} from '../../../sessions/constants' | ||
import { getRobotSessionById } from '../../../sessions/selectors' | ||
|
||
const sessionIncursRefetch: SessionType => boolean = sessionType => | ||
const isTargetSessionType: SessionType => boolean = sessionType => | ||
[ | ||
SESSION_TYPE_CALIBRATION_CHECK, | ||
SESSION_TYPE_TIP_LENGTH_CALIBRATION, | ||
SESSION_TYPE_DECK_CALIBRATION, | ||
SESSION_TYPE_PIPETTE_OFFSET_CALIBRATION, | ||
].includes(sessionType) | ||
|
||
const sessionIncursRefetch: ( | ||
state: State, | ||
robotName: string, | ||
sessionId: string | ||
) => boolean = (state, robotName, sessionId) => { | ||
const sessionType = | ||
getRobotSessionById(state, robotName, sessionId)?.sessionType || null | ||
if (sessionType) { | ||
return isTargetSessionType(sessionType) | ||
} else { | ||
return false | ||
} | ||
} | ||
|
||
export const fetchPipetteOffsetCalibrationsOnCalibrationEndEpic: Epic = ( | ||
action$, | ||
state$ | ||
) => { | ||
return action$.pipe( | ||
ofType(DELETE_SESSION_SUCCESS), | ||
withLatestFrom(state$, (a, s) => [a, getConnectedRobotName(s)]), | ||
ofType(DELETE_SESSION), | ||
withLatestFrom(state$, (a, s) => [ | ||
a, | ||
s, | ||
getConnectedRobotName(s), | ||
a.payload.sessionId, | ||
]), | ||
filter( | ||
([action, robotName]) => | ||
sessionIncursRefetch(action.payload.data.attributes.sessionType) && | ||
robotName != null | ||
([action, state, robotName, sessionId]) => | ||
robotName != null && sessionIncursRefetch(state, robotName, sessionId) | ||
), | ||
mergeMap(robotName => { | ||
return of(Actions.fetchPipetteOffsetCalibrations(robotName)) | ||
map(robotName => { | ||
return Actions.fetchPipetteOffsetCalibrations(robotName) | ||
}) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.