mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-08-28 05:25:33 +00:00
minor edits to make stuff work
This commit is contained in:
parent
bf4eb4790d
commit
09289dc468
5 changed files with 49 additions and 32 deletions
|
|
@ -9,5 +9,5 @@ export const getEnv = () => {
|
|||
// })
|
||||
|
||||
// return null
|
||||
return "production";
|
||||
return "development";
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<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>
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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)}
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue