From 7d1675010a33f277c8148a8ec1147ab066a0afbf Mon Sep 17 00:00:00 2001 From: Joseph Kavanagh Date: Wed, 15 Jan 2025 20:52:22 +0000 Subject: [PATCH] fix(ui): have VersionWithRefresh depend on original data (#516) --- .../components/modals/service-edit/version-with-refresh.tsx | 2 +- web/ui/react-app/src/utils/is-empty.tsx | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/web/ui/react-app/src/components/modals/service-edit/version-with-refresh.tsx b/web/ui/react-app/src/components/modals/service-edit/version-with-refresh.tsx index cc64f578..55ed05bf 100644 --- a/web/ui/react-app/src/components/modals/service-edit/version-with-refresh.tsx +++ b/web/ui/react-app/src/components/modals/service-edit/version-with-refresh.tsx @@ -63,7 +63,7 @@ const VersionWithRefresh: FC = ({ return convertUIDeployedVersionDataEditToAPI( original as DeployedVersionLookupEditType, ); - }, [serviceID, dataTarget]); + }, [original, serviceID, dataTarget]); const url: string | undefined = useWatch({ name: `${dataTarget}.url` }); const dataTargetErrors = useErrors(dataTarget, true); const { data, refetchData } = useValuesRefetch(dataTarget); diff --git a/web/ui/react-app/src/utils/is-empty.tsx b/web/ui/react-app/src/utils/is-empty.tsx index 724510ff..eae548fe 100644 --- a/web/ui/react-app/src/utils/is-empty.tsx +++ b/web/ui/react-app/src/utils/is-empty.tsx @@ -4,9 +4,8 @@ * @param arg - The array to check. * @returns true when array is empty, null, or undefined. false otherwise. */ -export const isEmptyArray = ( - arg: T, -): boolean => ((arg as unknown[]) ?? []).length === 0; +export const isEmptyArray = (arg?: unknown[]): arg is [] | undefined => + ((arg as unknown[]) ?? []).length === 0; export const isEmptyObject = | undefined>( arg: T,