Skip to content

Commit

Permalink
perf: loading ui
Browse files Browse the repository at this point in the history
  • Loading branch information
c121914yu committed Nov 17, 2024
1 parent df10b07 commit 94baff5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import { ChatRecordContext } from '@/web/core/chat/context/chatRecordContext';
import { ChatItemContext } from '@/web/core/chat/context/chatItemContext';
import { useChatStore } from '@/web/core/chat/context/storeChat';
import TimeBox from './components/TimeBox';
import MyBox from '@fastgpt/web/components/common/MyBox';

const ResponseTags = dynamic(() => import('./components/ResponseTags'));
const FeedbackModal = dynamic(() => import('./components/FeedbackModal'));
Expand Down Expand Up @@ -112,14 +113,15 @@ const ChatBox = ({
const router = useRouter();
const { t } = useTranslation();
const { toast } = useToast();
const { setLoading, feConfigs } = useSystemStore();
const { feConfigs } = useSystemStore();
const { isPc } = useSystem();
const TextareaDom = useRef<HTMLTextAreaElement>(null);
const chatController = useRef(new AbortController());
const questionGuideController = useRef(new AbortController());
const pluginController = useRef(new AbortController());
const isNewChatReplace = useRef(false);

const [isLoading, setIsLoading] = useState(false);
const [feedbackId, setFeedbackId] = useState<string>();
const [readFeedbackData, setReadFeedbackData] = useState<{
dataId: string;
Expand Down Expand Up @@ -584,7 +586,7 @@ const ChatBox = ({
if (!dataId || !onDelMessage) return;

return async () => {
setLoading(true);
setIsLoading(true);
const index = chatRecords.findIndex((item) => item.dataId === dataId);
const delHistory = chatRecords.slice(index);
try {
Expand All @@ -607,7 +609,7 @@ const ChatBox = ({
title: getErrText(error, 'Retry failed')
});
}
setLoading(false);
setIsLoading(false);
};
});
// delete one message(One human and the ai response)
Expand Down Expand Up @@ -1007,7 +1009,13 @@ const ChatBox = ({
// }, [isAutoExecute, sendPrompt, chatStarted, autoExecute, chatHistories.length]);

return (
<Flex flexDirection={'column'} h={'100%'} position={'relative'}>
<MyBox
isLoading={isLoading}
display={'flex'}
flexDirection={'column'}
h={'100%'}
position={'relative'}
>
<Script src={getWebReqUrl('/js/html2pdf.bundle.min.js')} strategy="lazyOnload"></Script>
{/* chat box container */}
{RenderRecords}
Expand Down Expand Up @@ -1114,7 +1122,7 @@ const ChatBox = ({
}}
/>
)}
</Flex>
</MyBox>
);
};

Expand Down
1 change: 0 additions & 1 deletion projects/app/src/web/core/chat/context/chatContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { BoxProps, useDisclosure } from '@chakra-ui/react';
import { useChatStore } from './storeChat';
import { getNanoid } from '@fastgpt/global/common/string/tools';
import { useScrollPagination } from '@fastgpt/web/hooks/useScrollPagination';
import { OutLinkChatAuthProps } from '@fastgpt/global/support/permission/chat';

type UpdateHistoryParams = {
chatId: UpdateHistoryProps['chatId'];
Expand Down

0 comments on commit 94baff5

Please sign in to comment.