From 2878ab37146267a9d92e1c11e77b12a115c7af4b Mon Sep 17 00:00:00 2001 From: Jamey Huffnagle Date: Thu, 5 Sep 2024 15:06:14 -0400 Subject: [PATCH] fix(app): fix "rerun protocol now" redirection delay (#16199) Closes RQA-3152 --- .../HistoricalProtocolRunOverflowMenu.tsx | 18 ++++++++++++++++-- .../ProtocolUpload/hooks/useCloneRun.ts | 13 ++++++------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/app/src/organisms/Devices/HistoricalProtocolRunOverflowMenu.tsx b/app/src/organisms/Devices/HistoricalProtocolRunOverflowMenu.tsx index 5632df49161..ead35bf5466 100644 --- a/app/src/organisms/Devices/HistoricalProtocolRunOverflowMenu.tsx +++ b/app/src/organisms/Devices/HistoricalProtocolRunOverflowMenu.tsx @@ -134,7 +134,10 @@ function MenuDropdown(props: MenuDropdownProps): JSX.Element { } const trackEvent = useTrackEvent() const { trackProtocolRunEvent } = useTrackProtocolRunEvent(runId, robotName) - const { reset, isRunControlLoading } = useRunControls(runId, onResetSuccess) + const { reset, isResetRunLoading, isRunControlLoading } = useRunControls( + runId, + onResetSuccess + ) const { deleteRun } = useDeleteRunMutation() const robot = useRobot(robotName) const robotSerialNumber = @@ -189,7 +192,18 @@ function MenuDropdown(props: MenuDropdownProps): JSX.Element { } data-testid="RecentProtocolRun_OverflowMenu_rerunNow" > - {t('rerun_now')} + + {t('rerun_now')} + {isResetRunLoading ? ( + + ) : null} + {isRobotOnWrongVersionOfSoftware && ( diff --git a/app/src/organisms/ProtocolUpload/hooks/useCloneRun.ts b/app/src/organisms/ProtocolUpload/hooks/useCloneRun.ts index d15bee033ed..870491b032c 100644 --- a/app/src/organisms/ProtocolUpload/hooks/useCloneRun.ts +++ b/app/src/organisms/ProtocolUpload/hooks/useCloneRun.ts @@ -36,13 +36,12 @@ export function useCloneRun( 'protocols', protocolKey, ]) - Promise.all([invalidateRuns, invalidateProtocols]) - .then(() => { - onSuccessCallback?.(response) - }) - .catch((e: Error) => { - console.error(`error invalidating runs query: ${e.message}`) - }) + Promise.all([invalidateRuns, invalidateProtocols]).catch((e: Error) => { + console.error(`error invalidating runs query: ${e.message}`) + }) + // The onSuccess callback is not awaited until query invalidation, because currently, in every instance this + // onSuccessCallback is utilized, we only use it for navigating. We may need to revisit this. + onSuccessCallback?.(response) }, }) const { createProtocolAnalysis } = useCreateProtocolAnalysisMutation(