mirror of https://github.com/buster-so/buster.git
version update should trigger full page refresh
Fallback to reload document in navigate
This commit is contained in:
parent
a29e6463cf
commit
9c256b2312
|
@ -3,7 +3,7 @@ import type React from 'react';
|
|||
import { useMemo, useState } from 'react';
|
||||
import { ErrorBoundary } from 'react-error-boundary';
|
||||
import { Button } from '@/components/ui/buttons';
|
||||
import { Paragraph, Text, Title } from '@/components/ui/typography';
|
||||
import { Paragraph, Title } from '@/components/ui/typography';
|
||||
import { useIsVersionChanged } from '@/context/AppVersion/useAppVersion';
|
||||
import { useMount } from '@/hooks/useMount';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
|
|
@ -18,6 +18,7 @@ export const useAppVersion = () => {
|
|||
...versionGetAppVersion,
|
||||
refetchOnReconnect: true,
|
||||
refetchOnMount: true,
|
||||
notifyOnChangeProps: ['data'],
|
||||
});
|
||||
const isChanged = checkNewVersion(data?.buildId);
|
||||
|
||||
|
@ -64,6 +65,7 @@ export const useIsVersionChanged = () => {
|
|||
const { data = false } = useQuery({
|
||||
...versionGetAppVersion,
|
||||
select: useCallback((data: { buildId: string }) => checkNewVersion(data.buildId), []),
|
||||
notifyOnChangeProps: ['data'],
|
||||
});
|
||||
return data;
|
||||
};
|
||||
|
|
|
@ -61,7 +61,6 @@ const PosthogWrapper: React.FC<PropsWithChildren> = ({ children }) => {
|
|||
import('posthog-js'),
|
||||
import('posthog-js/react'),
|
||||
]);
|
||||
console.log('posthog', posthog);
|
||||
|
||||
setPosthogModules({ posthog, PostHogProvider });
|
||||
} catch (error) {
|
||||
|
|
|
@ -2,6 +2,7 @@ import { useLocation, useNavigate } from '@tanstack/react-router';
|
|||
import { useEffect, useLayoutEffect, useRef } from 'react';
|
||||
import type { BusterChatResponseMessage_file } from '@/api/asset_interfaces/chat';
|
||||
import { useGetChatMessageMemoized } from '@/api/buster_rest/chats';
|
||||
import { useIsVersionChanged } from '@/context/AppVersion/useAppVersion';
|
||||
import { useHasLoadedChat } from '@/context/Chats/useGetChat';
|
||||
import {
|
||||
useGetChatMessageCompleted,
|
||||
|
@ -20,17 +21,15 @@ export const useAutoRedirectStreaming = ({
|
|||
}) => {
|
||||
const navigate = useNavigate();
|
||||
const getChatMessageMemoized = useGetChatMessageMemoized();
|
||||
const versionChanged = useIsVersionChanged();
|
||||
const isStreamFinished = useGetChatMessageCompleted({ messageId: lastMessageId });
|
||||
const lastReasoningMessageId = useGetChatMessageLastReasoningMessageId({
|
||||
messageId: lastMessageId,
|
||||
});
|
||||
const isFinishedReasoning = useGetChatMessageIsFinishedReasoning({ messageId: lastMessageId });
|
||||
const hasResponseFile = useGetChatMessageHasResponseFile({ messageId: lastMessageId });
|
||||
|
||||
const previousIsCompletedStream = useRef<boolean>(isStreamFinished);
|
||||
|
||||
const hasLoadedChat = useHasLoadedChat({ chatId: chatId || '' });
|
||||
|
||||
const hasReasoning = !!lastReasoningMessageId;
|
||||
|
||||
useLayoutEffect(() => {
|
||||
|
@ -63,7 +62,7 @@ export const useAutoRedirectStreaming = ({
|
|||
versionNumber: firstFile.version_number,
|
||||
});
|
||||
|
||||
navigate({ ...linkProps, replace: true });
|
||||
navigate({ ...linkProps, replace: true, reloadDocument: versionChanged });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,6 +75,7 @@ export const useAutoRedirectStreaming = ({
|
|||
messageId: lastMessageId,
|
||||
},
|
||||
replace: true,
|
||||
reloadDocument: versionChanged,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,14 @@ export const useAutoRedirectStreaming = ({
|
|||
chatId,
|
||||
},
|
||||
replace: true,
|
||||
reloadDocument: versionChanged,
|
||||
});
|
||||
}
|
||||
}, [isStreamFinished, hasReasoning, hasResponseFile, chatId, lastMessageId, isFinishedReasoning]); //only use these values to trigger the useEffect
|
||||
|
||||
useEffect(() => {
|
||||
if (!isStreamFinished && versionChanged) {
|
||||
window.location.reload();
|
||||
}
|
||||
}, [isStreamFinished, versionChanged]);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue