Skip to content

Commit

Permalink
fix: fixing the fetching problem
Browse files Browse the repository at this point in the history
  • Loading branch information
NarwhalChen committed Feb 10, 2025
1 parent f3521c5 commit 0cde182
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
4 changes: 0 additions & 4 deletions frontend/src/app/(main)/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ export default function Home() {

<ResizableHandle withHandle className="hidden md:flex" />

{curProject ? (
<ResizablePanel
defaultSize={50}
minSize={20}
Expand All @@ -142,9 +141,6 @@ export default function Home() {
>
<CodeEngine chatId={chatId} />
</ResizablePanel>
) : (
<></>
)}
</ResizablePanelGroup>
);
}
13 changes: 8 additions & 5 deletions frontend/src/components/code-engine/code-engine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ export function CodeEngine({ chatId }: { chatId: string }) {
useEffect(() => {
async function checkChatProject() {
if (curProject?.id) {
setIsProjectFinished(false);
const linkedProject = await pollChatProject(chatId);
console.log(linkedProject);
setIsProjectFinished(!!linkedProject);
setIsProjectFinished(true);
// setIsProjectFinished(false);
// if (
// chatId == '6730a482-2935-47f0-ad7a-43e7f17dc121' ||
Expand All @@ -60,6 +61,8 @@ export function CodeEngine({ chatId }: { chatId: string }) {
// await new Promise((resolve) => setTimeout(resolve, 10000));
// }
// setIsProjectFinished(true);
} else {
setIsProjectFinished(false);
}
}
checkChatProject();
Expand Down Expand Up @@ -266,10 +269,10 @@ export function CodeEngine({ chatId }: { chatId: string }) {
{!isProjectFinished && (
<motion.div
key="loader"
initial={{ opacity: 0, scale: 0.9 }} // 初始状态:透明 & 缩小
animate={{ opacity: 1, scale: 1 }} // 进入动画:淡入 & 正常大小
exit={{ opacity: 0, scale: 0.9 }} // 退出动画:淡出 & 缩小
transition={{ duration: 0.3, ease: 'easeOut' }} // 动画时间:0.3s
initial={{ opacity: 0, scale: 0.9 }}
animate={{ opacity: 1, scale: 1 }}
exit={{ opacity: 0, scale: 0.9 }}
transition={{ duration: 0.3, ease: 'easeOut' }}
className="absolute inset-0 bg-black bg-opacity-40 backdrop-blur-md flex items-center justify-center z-50"
>
<Loader className="w-10 h-10 text-white animate-spin" />
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/components/code-engine/project-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ export function ProjectProvider({ children }: { children: ReactNode }) {
});

const [createProject] = useMutation(CREATE_PROJECT, {
context: {
headers: {
Authorization: `Bearer ${validateToken}`,
},
},
onCompleted: (data) => {
setProjects((prev) =>
prev.some((p) => p.id === data.createProject.id)
Expand Down
5 changes: 2 additions & 3 deletions frontend/src/components/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,9 @@ export function ChatSideBar({
currentChatId={currentChatid}
title={chat.title}
onSelect={() => {
setCurProject(null);
pollChatProject(chat.id).then((p) => {
setCurProject((prev) =>
prev?.id !== p?.id ? p : prev
);
setCurProject(p);
});
window.history.replaceState({}, '', `/?id=${chat.id}`);
setCurrentChatid(chat.id);
Expand Down

0 comments on commit 0cde182

Please sign in to comment.