|
1 | | -import { useMemo, useState } from 'react' |
| 1 | +import { useEffect, useMemo, useState } from 'react' |
2 | 2 | import without from 'lodash/without' |
3 | 3 | import { useTranslation } from 'react-i18next' |
4 | 4 |
|
@@ -211,14 +211,25 @@ function useTipSelectionUtils( |
211 | 211 | ): UseTipSelectionUtilsResult { |
212 | 212 | const [selectedLocs, setSelectedLocs] = useState<WellGroup | null>(null) |
213 | 213 |
|
214 | | - const initialLocs = useInitialSelectedLocationsFrom( |
215 | | - recentRelevantFailedLabwareCmd |
216 | | - ) |
217 | | - |
218 | | - // Set the initial locs when they first become available or update. |
219 | | - if (selectedLocs !== initialLocs) { |
220 | | - setSelectedLocs(initialLocs) |
221 | | - } |
| 214 | + // Note that while other commands may have a wellName associated with them, |
| 215 | + // we are only interested in wells for the purposes of tip picking up. |
| 216 | + // Support state updates if the underlying well data changes, since this data is lazily retrieved and may change shortly |
| 217 | + // after Error Recovery launches. |
| 218 | + const initialWellName = |
| 219 | + recentRelevantFailedLabwareCmd != null && |
| 220 | + recentRelevantFailedLabwareCmd.commandType === 'pickUpTip' |
| 221 | + ? recentRelevantFailedLabwareCmd.params.wellName |
| 222 | + : null |
| 223 | + useEffect(() => { |
| 224 | + if ( |
| 225 | + recentRelevantFailedLabwareCmd != null && |
| 226 | + recentRelevantFailedLabwareCmd.commandType === 'pickUpTip' |
| 227 | + ) { |
| 228 | + setSelectedLocs({ |
| 229 | + [recentRelevantFailedLabwareCmd.params.wellName]: null, |
| 230 | + }) |
| 231 | + } |
| 232 | + }, [initialWellName]) |
222 | 233 |
|
223 | 234 | const deselectTips = (locations: string[]): void => { |
224 | 235 | setSelectedLocs(prevLocs => |
@@ -253,28 +264,6 @@ function useTipSelectionUtils( |
253 | 264 | } |
254 | 265 | } |
255 | 266 |
|
256 | | -// Set the initial well selection to be the last pickup tip location for the pipette used in the failed command. |
257 | | -export function useInitialSelectedLocationsFrom( |
258 | | - recentRelevantFailedLabwareCmd: FailedCommandRelevantLabware |
259 | | -): WellGroup | null { |
260 | | - const [initialWells, setInitialWells] = useState<WellGroup | null>(null) |
261 | | - |
262 | | - // Note that while other commands may have a wellName associated with them, |
263 | | - // we are only interested in wells for the purposes of tip picking up. |
264 | | - // Support state updates if the underlying data changes, since this data is lazily loaded and may change shortly |
265 | | - // after Error Recovery launches. |
266 | | - if ( |
267 | | - recentRelevantFailedLabwareCmd != null && |
268 | | - recentRelevantFailedLabwareCmd.commandType === 'pickUpTip' && |
269 | | - (initialWells == null || |
270 | | - !(recentRelevantFailedLabwareCmd.params.wellName in initialWells)) |
271 | | - ) { |
272 | | - setInitialWells({ [recentRelevantFailedLabwareCmd.params.wellName]: null }) |
273 | | - } |
274 | | - |
275 | | - return initialWells |
276 | | -} |
277 | | - |
278 | 267 | // Get the name of the relevant labware relevant to the failed command, if any. |
279 | 268 | export function getFailedCmdRelevantLabware( |
280 | 269 | protocolAnalysis: ErrorRecoveryFlowsProps['protocolAnalysis'], |
|
0 commit comments