feat: disabled same url check for traces query builder as well

This commit is contained in:
Sahil 2025-02-28 13:03:10 +05:30 committed by Sahil Khan
parent cb69cd91a0
commit 114a979b14
2 changed files with 10 additions and 5 deletions

View File

@ -13,7 +13,7 @@ interface SafeNavigateParams {
} }
interface UseSafeNavigateProps { interface UseSafeNavigateProps {
enableSameURLCheck?: boolean; preventSameUrlNavigation?: boolean;
} }
const areUrlsEffectivelySame = (url1: URL, url2: URL): boolean => { const areUrlsEffectivelySame = (url1: URL, url2: URL): boolean => {
@ -83,7 +83,9 @@ const isDefaultNavigation = (currentUrl: URL, targetUrl: URL): boolean => {
return newKeys.length > 0; return newKeys.length > 0;
}; };
export const useSafeNavigate = ( export const useSafeNavigate = (
{ enableSameURLCheck }: UseSafeNavigateProps = { enableSameURLCheck: true }, { preventSameUrlNavigation }: UseSafeNavigateProps = {
preventSameUrlNavigation: true,
},
): { ): {
safeNavigate: ( safeNavigate: (
to: string | SafeNavigateParams, to: string | SafeNavigateParams,
@ -114,7 +116,7 @@ export const useSafeNavigate = (
const urlsAreSame = areUrlsEffectivelySame(currentUrl, targetUrl); const urlsAreSame = areUrlsEffectivelySame(currentUrl, targetUrl);
const isDefaultParamsNavigation = isDefaultNavigation(currentUrl, targetUrl); const isDefaultParamsNavigation = isDefaultNavigation(currentUrl, targetUrl);
if (enableSameURLCheck && urlsAreSame) { if (preventSameUrlNavigation && urlsAreSame) {
return; return;
} }
@ -135,7 +137,7 @@ export const useSafeNavigate = (
); );
} }
}, },
[navigate, location.pathname, location.search, enableSameURLCheck], [navigate, location.pathname, location.search, preventSameUrlNavigation],
); );
return { safeNavigate }; return { safeNavigate };

View File

@ -764,7 +764,10 @@ export function QueryBuilderProvider({
); );
const { safeNavigate } = useSafeNavigate({ const { safeNavigate } = useSafeNavigate({
enableSameURLCheck: !(initialDataSource === DataSource.LOGS), preventSameUrlNavigation: !(
initialDataSource === DataSource.LOGS ||
initialDataSource === DataSource.TRACES
),
}); });
const redirectWithQueryBuilderData = useCallback( const redirectWithQueryBuilderData = useCallback(