Skip to content

Commit

Permalink
move components
Browse files Browse the repository at this point in the history
  • Loading branch information
bracesproul committed Oct 29, 2024
1 parent 354c235 commit 8904702
Show file tree
Hide file tree
Showing 31 changed files with 662 additions and 633 deletions.
23 changes: 19 additions & 4 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,40 @@
"use client";
import { Canvas } from "@/components/Canvas";
import { useEffect } from "react";
import { addAssistantIdToUser } from "@/lib/supabase/add_assistant_id_to_user";
import { CanvasLoading } from "@/components/CanvasLoading";
import { CanvasLoading, Canvas } from "@/components/canvas";
import { useUser } from "@/hooks/useUser";
import { useThread } from "@/hooks/useThread";

export default function Home() {
const { user, getUser } = useUser();
const { threadId, assistantId, searchOrCreateThread, getOrCreateAssistant } =
useThread();

useEffect(() => {
getUser();
}, []);

useEffect(() => {
if (typeof window === "undefined") return;
if (!user) return;

if (!threadId) {
searchOrCreateThread(user.id);
}

if (!assistantId) {
getOrCreateAssistant();
}
}, [user]);

useEffect(() => {
if (typeof window === "undefined" || !user) return;
addAssistantIdToUser();
}, [user]);

if (!user) {
if (!user || !assistantId || !threadId) {
return <CanvasLoading />;
}

return <Canvas />;
return <Canvas threadId={threadId} assistantId={assistantId} user={user} />;
}
Loading

0 comments on commit 8904702

Please sign in to comment.