Skip to content

Commit

Permalink
Move redirect for deleted run to onError from useEffect
Browse files Browse the repository at this point in the history
  • Loading branch information
smb2268 committed Aug 19, 2024
1 parent ad103d3 commit 52fc0f8
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions app/src/pages/RunSummary/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,13 @@ export function RunSummary(): JSX.Element {
const { t } = useTranslation('run_details')
const navigate = useNavigate()
const host = useHost()
const { data: runRecord } = useNotifyRunQuery(runId, { staleTime: Infinity })
const { data: runRecord } = useNotifyRunQuery(runId, {
staleTime: Infinity,
onError: () => {
// in case the run is remotely deleted by a desktop app, navigate to the dash
navigate('/')
},
})
const isRunCurrent = Boolean(
useNotifyRunQuery(runId, { refetchInterval: CURRENT_RUN_POLL_MS })?.data
?.data?.current
Expand Down Expand Up @@ -135,15 +141,6 @@ export function RunSummary(): JSX.Element {
}
}, [isRunCurrent, enteredER])

React.useEffect(() => {
// in case the run is remotely deleted by a desktop app, navigate to the dash
console.log('run record == null: ', runRecord == null)
console.log('is quick transfer: ', isQuickTransfer)
if (runRecord == null && isQuickTransfer) {
navigate('/')
}
}, [runRecord, isQuickTransfer])

const { reset, isResetRunLoading } = useRunControls(runId, onCloneRunSuccess)
const trackEvent = useTrackEvent()
const { closeCurrentRun, isClosingCurrentRun } = useCloseCurrentRun()
Expand Down

0 comments on commit 52fc0f8

Please sign in to comment.