diff --git a/app/src/resources/runs/useNotifyRunQuery.ts b/app/src/resources/runs/useNotifyRunQuery.ts index ba742b69e03..27b15a2d8e2 100644 --- a/app/src/resources/runs/useNotifyRunQuery.ts +++ b/app/src/resources/runs/useNotifyRunQuery.ts @@ -20,7 +20,7 @@ export function useNotifyRunQuery( const httpQueryResult = useRunQuery(runId, queryOptionsNotify, hostOverride) - if (shouldRefetch) { + if (shouldRefetch && runId != null) { void httpQueryResult.refetch() } diff --git a/app/src/resources/runs/useRunStatus.ts b/app/src/resources/runs/useRunStatus.ts index a1a1d5dc7cd..221819da76e 100644 --- a/app/src/resources/runs/useRunStatus.ts +++ b/app/src/resources/runs/useRunStatus.ts @@ -1,9 +1,7 @@ -import { useRef } from 'react' import { RUN_ACTION_TYPE_PLAY, RUN_STATUS_IDLE, RUN_STATUS_RUNNING, - RUN_STATUSES_TERMINAL, } from '@opentrons/api-client' import { useNotifyRunQuery } from './useNotifyRunQuery' import { DEFAULT_STATUS_REFETCH_INTERVAL } from './constants' @@ -15,14 +13,8 @@ export function useRunStatus( runId: string | null, options?: UseQueryOptions ): RunStatus | null { - const lastRunStatus = useRef(null) - const { data } = useNotifyRunQuery(runId ?? null, { refetchInterval: DEFAULT_STATUS_REFETCH_INTERVAL, - enabled: - lastRunStatus.current == null || - !(RUN_STATUSES_TERMINAL as RunStatus[]).includes(lastRunStatus.current), - onSuccess: data => (lastRunStatus.current = data?.data?.status ?? null), ...options, })