mirror of https://github.com/buster-so/buster.git
prefetch chat home
This commit is contained in:
parent
9f052724d3
commit
a052036440
|
@ -65,7 +65,7 @@ export const ChatResponseReasoning: React.FC<{
|
||||||
}, [isReasonginFileSelected, messageId, chatId]);
|
}, [isReasonginFileSelected, messageId, chatId]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Link href={href}>
|
<Link href={href} prefetch>
|
||||||
<AnimatePresence initial={!isCompletedStream} mode="wait">
|
<AnimatePresence initial={!isCompletedStream} mode="wait">
|
||||||
<motion.div
|
<motion.div
|
||||||
{...animations}
|
{...animations}
|
||||||
|
|
|
@ -6,6 +6,9 @@ import { useChatLayoutContextSelector } from '../../ChatLayoutContext';
|
||||||
import { FileContainerHeaderVersionHistory } from './FileContainerHeaderVersionHistory';
|
import { FileContainerHeaderVersionHistory } from './FileContainerHeaderVersionHistory';
|
||||||
import { SelectedFileButtonsRecord, SelectedFileSegmentRecord } from './config';
|
import { SelectedFileButtonsRecord, SelectedFileSegmentRecord } from './config';
|
||||||
import { FileType } from '@/api/asset_interfaces/chat';
|
import { FileType } from '@/api/asset_interfaces/chat';
|
||||||
|
import { useRouter } from 'next/router';
|
||||||
|
import { useMount } from '@/hooks';
|
||||||
|
import { BusterRoutes, createBusterRoute } from '@/routes';
|
||||||
|
|
||||||
export const FileContainerHeader: React.FC = React.memo(() => {
|
export const FileContainerHeader: React.FC = React.memo(() => {
|
||||||
const selectedFileType = useChatLayoutContextSelector((x) => x.selectedFile?.type);
|
const selectedFileType = useChatLayoutContextSelector((x) => x.selectedFile?.type);
|
||||||
|
@ -28,6 +31,7 @@ const FileContainerHeaderStandard: React.FC<{
|
||||||
selectedFileId: string | undefined;
|
selectedFileId: string | undefined;
|
||||||
selectedFileType: FileType | undefined;
|
selectedFileType: FileType | undefined;
|
||||||
}> = ({ selectedFileId, selectedFileType }) => {
|
}> = ({ selectedFileId, selectedFileType }) => {
|
||||||
|
const router = useRouter();
|
||||||
const chatId = useChatLayoutContextSelector((x) => x.chatId);
|
const chatId = useChatLayoutContextSelector((x) => x.chatId);
|
||||||
const selectedFileView = useChatLayoutContextSelector((x) => x.selectedFileView);
|
const selectedFileView = useChatLayoutContextSelector((x) => x.selectedFileView);
|
||||||
const onCollapseFileClick = useChatLayoutContextSelector((state) => state.onCollapseFileClick);
|
const onCollapseFileClick = useChatLayoutContextSelector((state) => state.onCollapseFileClick);
|
||||||
|
@ -50,6 +54,17 @@ const FileContainerHeaderStandard: React.FC<{
|
||||||
[selectedFileType]
|
[selectedFileType]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
useMount(() => {
|
||||||
|
if (chatId) {
|
||||||
|
router.prefetch(
|
||||||
|
createBusterRoute({
|
||||||
|
route: BusterRoutes.APP_CHAT_ID,
|
||||||
|
chatId
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="flex min-w-0 shrink items-center gap-1.5 overflow-hidden">
|
<div className="flex min-w-0 shrink items-center gap-1.5 overflow-hidden">
|
||||||
|
|
Loading…
Reference in New Issue