Skip to content

Commit

Permalink
fix(app): add deck config query refetch interval (#14122)
Browse files Browse the repository at this point in the history
refetches the deck config on a 5 second interval on the device details page and in hooks that
determine location conflicts

closes RQA-1993
  • Loading branch information
brenthagen authored Dec 7, 2023
1 parent 28ede47 commit 9c008f2
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 5 deletions.
5 changes: 4 additions & 1 deletion app/src/organisms/DeviceDetailsDeckConfiguration/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { useRunStatuses } from '../Devices/hooks'

import type { CutoutId } from '@opentrons/shared-data'

const DECK_CONFIG_REFETCH_INTERVAL = 5000
const RUN_REFETCH_INTERVAL = 5000

interface DeviceDetailsDeckConfigurationProps {
Expand All @@ -59,7 +60,9 @@ export function DeviceDetailsDeckConfiguration({
null
)

const deckConfig = useDeckConfigurationQuery().data ?? []
const deckConfig =
useDeckConfigurationQuery({ refetchInterval: DECK_CONFIG_REFETCH_INTERVAL })
.data ?? []
const { updateDeckConfiguration } = useUpdateDeckConfigurationMutation()
const { isRunRunning } = useRunStatuses()
const { data: maintenanceRunData } = useCurrentMaintenanceRun({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@ export interface ModuleRenderInfoById {
[moduleId: string]: ModuleRenderInfoForProtocol
}

const DECK_CONFIG_REFETCH_INTERVAL = 5000

export function useModuleRenderInfoForProtocolById(
runId: string
): ModuleRenderInfoById {
const robotProtocolAnalysis = useMostRecentCompletedAnalysis(runId)
const { data: deckConfig } = useDeckConfigurationQuery()
const { data: deckConfig } = useDeckConfigurationQuery({
refetchInterval: DECK_CONFIG_REFETCH_INTERVAL,
})
const storedProtocolAnalysis = useStoredProtocolAnalysis(runId)
const protocolAnalysis = robotProtocolAnalysis ?? storedProtocolAnalysis
const attachedModules = useAttachedModules()
Expand Down
5 changes: 4 additions & 1 deletion app/src/organisms/ProtocolSetupModulesAndDeck/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ import type { ProtocolCalibrationStatus } from '../../organisms/Devices/hooks'
import type { AttachedProtocolModuleMatch } from './utils'

const ATTACHED_MODULE_POLL_MS = 5000
const DECK_CONFIG_REFETCH_INTERVAL = 5000

interface RenderModuleStatusProps {
isModuleReady: boolean
Expand Down Expand Up @@ -340,7 +341,9 @@ export function ProtocolSetupModulesAndDeck({
prepCommandErrorMessage,
setPrepCommandErrorMessage,
] = React.useState<string>('')
const { data: deckConfig } = useDeckConfigurationQuery()
const { data: deckConfig } = useDeckConfigurationQuery({
refetchInterval: DECK_CONFIG_REFETCH_INTERVAL,
})
const mostRecentAnalysis = useMostRecentCompletedAnalysis(runId)

const deckDef = getDeckDefFromRobotType(FLEX_ROBOT_TYPE)
Expand Down
6 changes: 5 additions & 1 deletion app/src/pages/Protocols/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ export type ProtocolHardware =
| ProtocolGripper
| ProtocolFixture

const DECK_CONFIG_REFETCH_INTERVAL = 5000

export const useRequiredProtocolHardwareFromAnalysis = (
analysis: CompletedProtocolAnalysis | null
): { requiredProtocolHardware: ProtocolHardware[]; isLoading: boolean } => {
Expand All @@ -79,7 +81,9 @@ export const useRequiredProtocolHardwareFromAnalysis = (

const robotType = FLEX_ROBOT_TYPE
const deckDef = getDeckDefFromRobotType(robotType)
const { data: deckConfig = [] } = useDeckConfigurationQuery()
const { data: deckConfig = [] } = useDeckConfigurationQuery({
refetchInterval: DECK_CONFIG_REFETCH_INTERVAL,
})
const deckConfigCompatibility = useDeckConfigurationCompatibility(
robotType,
analysis
Expand Down
6 changes: 5 additions & 1 deletion app/src/resources/deck_configuration/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@ import type {
RobotType,
} from '@opentrons/shared-data'

const DECK_CONFIG_REFETCH_INTERVAL = 5000

export interface CutoutConfigAndCompatibility extends CutoutConfigProtocolSpec {
compatibleCutoutFixtureIds: CutoutFixtureId[]
}
export function useDeckConfigurationCompatibility(
robotType: RobotType,
protocolAnalysis: CompletedProtocolAnalysis | ProtocolAnalysisOutput | null
): CutoutConfigAndCompatibility[] {
const deckConfig = useDeckConfigurationQuery().data ?? []
const deckConfig =
useDeckConfigurationQuery({ refetchInterval: DECK_CONFIG_REFETCH_INTERVAL })
.data ?? []
if (robotType !== FLEX_ROBOT_TYPE) return []
const deckDef = getDeckDefFromRobotType(robotType)
const allAddressableAreas =
Expand Down

0 comments on commit 9c008f2

Please sign in to comment.