check for same page navigation

This commit is contained in:
Nate Kelley 2025-09-27 19:13:49 -06:00
parent 9e6e4fa608
commit 00caf1fe0a
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
2 changed files with 10 additions and 6 deletions

View File

@ -6,9 +6,7 @@ import { ReportEditorSkeleton } from './ReportEditorSkeleton';
const DynamicReportEditorBase = lazy(() =>
import('@/components/ui/report/ReportEditor').then((mod) => {
return {
default: mod.ReportEditor,
};
return { default: mod.ReportEditor };
})
);

View File

@ -1,4 +1,4 @@
import { useNavigate } from '@tanstack/react-router';
import { useLocation, useNavigate } from '@tanstack/react-router';
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
import type { BusterChatResponseMessage_file } from '@/api/asset_interfaces/chat';
import { useGetChatMessageMemoized } from '@/api/buster_rest/chats';
@ -10,6 +10,7 @@ import {
useGetChatMessageIsFinishedReasoning,
useGetChatMessageLastReasoningMessageId,
} from '@/context/Chats/useGetChatMessage';
import { useBuildLocation } from '@/context/Routes/useRouteBuilder';
import { useWindowFocus } from '@/hooks/useWindowFocus';
import { assetParamsToRoute } from '@/lib/assets/assetParamsToRoute';
@ -21,6 +22,8 @@ export const useAutoRedirectStreaming = ({
chatId: string | undefined;
}) => {
const navigate = useNavigate();
const location = useLocation();
const buildLocation = useBuildLocation();
const getChatMessageMemoized = useGetChatMessageMemoized();
const versionChanged = useIsVersionChanged();
const isStreamFinished = useGetChatMessageCompleted({ messageId: lastMessageId });
@ -67,8 +70,11 @@ export const useAutoRedirectStreaming = ({
chatId,
versionNumber: firstFile.version_number,
});
navigate({ ...linkProps, replace: true, reloadDocument: versionChanged });
const builtLocation = buildLocation(linkProps);
const isOnSamePage = builtLocation.pathname === location.pathname;
if (!isOnSamePage) {
navigate({ ...linkProps, replace: true, reloadDocument: versionChanged });
}
}
previousIsCompletedStream.current = true;