From 09289dc4680d2b24fcf7e1234e0235b718712291 Mon Sep 17 00:00:00 2001 From: Dhravya Date: Thu, 11 Apr 2024 19:00:34 -0700 Subject: [PATCH] minor edits to make stuff work --- apps/extension/src/util.ts | 2 +- apps/web/src/app/page.tsx | 52 ++++++++++++------- apps/web/src/components/Main.tsx | 13 +++-- .../src/components/Sidebar/FilterCombobox.tsx | 8 +-- .../src/components/Sidebar/MemoriesBar.tsx | 6 +-- 5 files changed, 49 insertions(+), 32 deletions(-) diff --git a/apps/extension/src/util.ts b/apps/extension/src/util.ts index d2ea35d3..0b73b6c8 100644 --- a/apps/extension/src/util.ts +++ b/apps/extension/src/util.ts @@ -9,5 +9,5 @@ export const getEnv = () => { // }) // return null - return "production"; + return "development"; }; diff --git a/apps/web/src/app/page.tsx b/apps/web/src/app/page.tsx index 55397545..419daa5a 100644 --- a/apps/web/src/app/page.tsx +++ b/apps/web/src/app/page.tsx @@ -10,7 +10,11 @@ import { import { and, eq, inArray, not } from "drizzle-orm"; import { cookies, headers } from "next/headers"; import { redirect } from "next/navigation"; -import { fetchContentForSpace, fetchFreeMemories, transformContent } from "../../types/memory"; +import { + fetchContentForSpace, + fetchFreeMemories, + transformContent, +} from "../../types/memory"; import { MemoryProvider } from "@/contexts/MemoryContext"; import Content from "./content"; import { searchMemoriesAndSpaces } from "@/actions/db"; @@ -47,32 +51,35 @@ export default async function Home() { return redirect("/api/auth/signin"); } + console.log(storedContent.user.name); const collectedSpaces = await db .select() .from(space) - .where( - and(eq(storedContent.user, userData.id), not(eq(space.name, "none"))), - ); - + .where(and(eq(space.user, userData.id), not(eq(space.name, "none")))); // Fetch only first 3 content of each spaces - let contents: typeof storedContent.$inferSelect[] = [] - - await Promise.all([collectedSpaces.forEach(async (space) => { - contents = [...contents, ...(await fetchContentForSpace(space.id, { - offset: 0, - limit: 3 - }))] - })]) + let contents: (typeof storedContent.$inferSelect)[] = []; - // freeMemories - const freeMemories = await fetchFreeMemories(userData.id) + await Promise.all([ + collectedSpaces.forEach(async (space) => { + contents = [ + ...contents, + ...(await fetchContentForSpace(space.id, { + offset: 0, + limit: 3, + })), + ]; + }), + ]); - // @dhravya test these 3 functions - fetchFreeMemories - fetchContentForSpace - searchMemoriesAndSpaces + // freeMemories + const freeMemories = await fetchFreeMemories(userData.id); + + // @dhravya test these 3 functions + fetchFreeMemories; + fetchContentForSpace; + searchMemoriesAndSpaces; collectedSpaces.push({ id: 1, @@ -81,7 +88,12 @@ export default async function Home() { }); return ( - + {/* */} diff --git a/apps/web/src/components/Main.tsx b/apps/web/src/components/Main.tsx index c7bb3f1e..f3c45f2a 100644 --- a/apps/web/src/components/Main.tsx +++ b/apps/web/src/components/Main.tsx @@ -185,9 +185,14 @@ export default function Main({ sidebarOpen }: { sidebarOpen: boolean }) { }, ); - const sourcesInJson = (await sourcesResponse.json()) as { - ids: string[]; - }; + console.log(await sourcesResponse.json()); + + // const sourcesInJson = (await sourcesResponse.json()) as { + // ids: string[]; + // }; + + // console.log(sourcesInJson) + const sourcesInJson = { ids: [] }; setIsAiLoading(false); setChatHistory((prev) => { @@ -205,7 +210,7 @@ export default function Main({ sidebarOpen }: { sidebarOpen: boolean }) { }); const actualSelectedSpaces = selectedSpaces.map( - (space) => spaces.find((s) => s.id === space)?.title ?? "", + (space) => spaces.find((s) => s.id === space)?.name ?? "", ); const response = await fetch( diff --git a/apps/web/src/components/Sidebar/FilterCombobox.tsx b/apps/web/src/components/Sidebar/FilterCombobox.tsx index 0a93ee55..bd432215 100644 --- a/apps/web/src/components/Sidebar/FilterCombobox.tsx +++ b/apps/web/src/components/Sidebar/FilterCombobox.tsx @@ -95,7 +95,7 @@ export function FilterSpaces({ filter={(val, search) => spaces .find((s) => s.id.toString() === val) - ?.title.toLowerCase() + ?.name.toLowerCase() .includes(search.toLowerCase().trim()) ? 1 : 0 @@ -128,7 +128,7 @@ export function FilterSpaces({ className="text-rgray-11" > - {space.title} + {space.name} {selectedSpaces.includes(space.id)} spaces .find((s) => s.id.toString() === val) - ?.title.toLowerCase() + ?.name.toLowerCase() .includes(search.toLowerCase().trim()) ? 1 : 0 @@ -245,7 +245,7 @@ export function FilterMemories({ className="text-rgray-11" > - {space.title} + {space.name} {selectedSpaces.includes(space.id)} void, onClick?: () => void }) { +}: StoredSpace & { onDelete: () => void; onClick?: () => void }) { const [itemRef, animateItem] = useAnimate(); const { width } = useViewport(); @@ -255,7 +255,7 @@ export function SpaceItem({ }; }} /> - {content.length > 2 ? ( + {/* {content.length > 2 ? ( c.image).reverse() as string[]} /> - )} + )} */} ); }