aboutsummaryrefslogtreecommitdiff
path: root/apps/web/src
diff options
context:
space:
mode:
authorDhravya <[email protected]>2024-04-11 19:00:34 -0700
committerDhravya <[email protected]>2024-04-11 19:00:34 -0700
commit09289dc4680d2b24fcf7e1234e0235b718712291 (patch)
tree41f317a90f63074dc373a855145b29d249d9d205 /apps/web/src
parentadd search to context (diff)
downloadsupermemory-09289dc4680d2b24fcf7e1234e0235b718712291.tar.xz
supermemory-09289dc4680d2b24fcf7e1234e0235b718712291.zip
minor edits to make stuff work
Diffstat (limited to 'apps/web/src')
-rw-r--r--apps/web/src/app/page.tsx52
-rw-r--r--apps/web/src/components/Main.tsx13
-rw-r--r--apps/web/src/components/Sidebar/FilterCombobox.tsx8
-rw-r--r--apps/web/src/components/Sidebar/MemoriesBar.tsx6
4 files changed, 48 insertions, 31 deletions
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)[] = [];
+
+ await Promise.all([
+ collectedSpaces.forEach(async (space) => {
+ contents = [
+ ...contents,
+ ...(await fetchContentForSpace(space.id, {
+ offset: 0,
+ limit: 3,
+ })),
+ ];
+ }),
+ ]);
- // freeMemories
- const freeMemories = await fetchFreeMemories(userData.id)
+ // freeMemories
+ const freeMemories = await fetchFreeMemories(userData.id);
- // @dhravya test these 3 functions
- fetchFreeMemories
- fetchContentForSpace
- searchMemoriesAndSpaces
+ // @dhravya test these 3 functions
+ fetchFreeMemories;
+ fetchContentForSpace;
+ searchMemoriesAndSpaces;
collectedSpaces.push({
id: 1,
@@ -81,7 +88,12 @@ export default async function Home() {
});
return (
- <MemoryProvider user={userData} spaces={collectedSpaces} freeMemories={freeMemories} cachedMemories={contents}>
+ <MemoryProvider
+ user={userData}
+ spaces={collectedSpaces}
+ freeMemories={freeMemories}
+ cachedMemories={contents}
+ >
<Content jwt={token} />
{/* <MessagePoster jwt={token} /> */}
</MemoryProvider>
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"
>
<SpaceIcon className="mr-2 h-4 w-4" />
- {space.title}
+ {space.name}
{selectedSpaces.includes(space.id)}
<Check
data-state-on={selectedSpaces.includes(space.id)}
@@ -212,7 +212,7 @@ export function FilterMemories({
filter={(val, search) =>
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"
>
<SpaceIcon className="mr-2 h-4 w-4" />
- {space.title}
+ {space.name}
{selectedSpaces.includes(space.id)}
<Check
data-state-on={selectedSpaces.includes(space.id)}
diff --git a/apps/web/src/components/Sidebar/MemoriesBar.tsx b/apps/web/src/components/Sidebar/MemoriesBar.tsx
index 133e9957..769e6296 100644
--- a/apps/web/src/components/Sidebar/MemoriesBar.tsx
+++ b/apps/web/src/components/Sidebar/MemoriesBar.tsx
@@ -150,7 +150,7 @@ export function SpaceItem({
id,
onDelete,
onClick,
-}: StoredSpace & { onDelete: () => 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 ? (
<MemoryWithImages3
className="h-24 w-24"
id={id.toString()}
@@ -273,7 +273,7 @@ export function SpaceItem({
id={id.toString()}
images={content.map((c) => c.image).reverse() as string[]}
/>
- )}
+ )} */}
</motion.div>
);
}