diff options
| author | yxshv <[email protected]> | 2024-04-14 14:29:23 +0530 |
|---|---|---|
| committer | yxshv <[email protected]> | 2024-04-14 14:29:23 +0530 |
| commit | fa39265142a7aa452a273e4290d58757af2786bb (patch) | |
| tree | 52e2e07d2a20009d650ed0b3ebe60aaab87d81ff /apps/web/src/components/Main.tsx | |
| parent | fixed notes vectorize (diff) | |
| download | supermemory-fa39265142a7aa452a273e4290d58757af2786bb.tar.xz supermemory-fa39265142a7aa452a273e4290d58757af2786bb.zip | |
new modals
Diffstat (limited to 'apps/web/src/components/Main.tsx')
| -rw-r--r-- | apps/web/src/components/Main.tsx | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/apps/web/src/components/Main.tsx b/apps/web/src/components/Main.tsx index bbdb630d..df6a08bf 100644 --- a/apps/web/src/components/Main.tsx +++ b/apps/web/src/components/Main.tsx @@ -13,6 +13,7 @@ import { useRouter, useSearchParams } from "next/navigation"; import { useMemory } from "@/contexts/MemoryContext"; import Image from "next/image"; +import { getMemoriesFromUrl } from "@/actions/db"; function supportsDVH() { try { @@ -185,11 +186,25 @@ export default function Main({ sidebarOpen }: { sidebarOpen: boolean }) { }, ); - const sourcesInJson = (await sourcesResponse.json()) as { - ids: string[]; - }; - console.log(sourcesInJson); + const sourcesInJson = getIdsFromSource(((await sourcesResponse.json()) as { + ids: string[] + }).ids) ?? []; + + + const notesInSources = sourcesInJson.filter( + (urls) => urls.startsWith("https://notes.supermemory.dhr.wtf/") + ) + const nonNotes = sourcesInJson.filter( + i => !notesInSources.includes(i) + ) + + const fetchedTitles = await getMemoriesFromUrl(notesInSources); + + const sources = [ + ...nonNotes.map(n => ({ isNote: false, source: n ?? "<unnamed>" })), + ...fetchedTitles.map(n => ({ isNote: true, source: n.title ?? "<unnamed>" })) + ] setIsAiLoading(false); setChatHistory((prev) => { @@ -200,7 +215,7 @@ export default function Main({ sidebarOpen }: { sidebarOpen: boolean }) { ...lastMessage, answer: { parts: lastMessage.answer.parts, - sources: getIdsFromSource(sourcesInJson.ids) ?? [], + sources }, }, ]; |