Skip to content

Commit

Permalink
fix(app): allow ODD to poll for completed analysis on protocol setup
Browse files Browse the repository at this point in the history
Prevent bug where odd will not proceed past protocol setup screen because of lack of completed
analysis

RQA-2074
  • Loading branch information
b-cooper committed Dec 13, 2023
1 parent bfd1420 commit bdc3f5f
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions app/src/pages/OnDeviceDisplay/ProtocolSetup/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react'
import last from 'lodash/last'
import { useSelector } from 'react-redux'
import { useTranslation } from 'react-i18next'
import { useHistory, useParams } from 'react-router-dom'
Expand Down Expand Up @@ -28,6 +29,7 @@ import {
useRunQuery,
useInstrumentsQuery,
useDoorQuery,
useProtocolAnalysisAsDocumentQuery,
} from '@opentrons/react-api-client'
import {
getDeckDefFromRobotType,
Expand All @@ -50,7 +52,6 @@ import {
useRequiredProtocolHardwareFromAnalysis,
useMissingProtocolHardwareFromAnalysis,
} from '../../Protocols/hooks'
import { useMostRecentCompletedAnalysis } from '../../../organisms/LabwarePositionCheck/useMostRecentCompletedAnalysis'
import { getProtocolModulesInfo } from '../../../organisms/Devices/ProtocolRun/utils/getProtocolModulesInfo'
import { ProtocolSetupLabware } from '../../../organisms/ProtocolSetupLabware'
import { ProtocolSetupModulesAndDeck } from '../../../organisms/ProtocolSetupModulesAndDeck'
Expand Down Expand Up @@ -199,6 +200,7 @@ export function ProtocolSetupStep({
)
}

const ANALYSIS_POLL_MS = 5000
interface PrepareToRunProps {
runId: string
setSetupScreen: React.Dispatch<React.SetStateAction<SetupScreens>>
Expand Down Expand Up @@ -239,7 +241,29 @@ function PrepareToRun({
protocolRecord?.data.metadata.protocolName ??
protocolRecord?.data.files[0].name ??
''
const mostRecentAnalysis = useMostRecentCompletedAnalysis(runId)

const mostRecentAnalysisSummary = last(protocolRecord?.data.analysisSummaries)
const [
isPollingForCompletedAnalysis,
setIsPollingForCompletedAnalysis,
] = React.useState<boolean>(mostRecentAnalysisSummary?.status !== 'completed')

const { data: mostRecentAnalysis = null} = useProtocolAnalysisAsDocumentQuery(
protocolId,
last(protocolRecord?.data.analysisSummaries)?.id ?? null,
{
enabled: protocolRecord != null && isPollingForCompletedAnalysis,
refetchInterval: ANALYSIS_POLL_MS,
}
)

React.useEffect(() => {
if (mostRecentAnalysis?.status === 'completed') {
setIsPollingForCompletedAnalysis(false)
} else {
setIsPollingForCompletedAnalysis(true)
}
}, [mostRecentAnalysis?.status])

const robotType = useRobotType(robotName)
const { launchLPC, LPCWizard } = useLaunchLPC(runId, robotType, protocolName)
Expand Down

0 comments on commit bdc3f5f

Please sign in to comment.