mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-08-28 05:25:33 +00:00
Optimize onboarding chat document creation with Promise.all (#822)
This commit is contained in:
parent
a0e3d7d192
commit
7fd36eaebc
1 changed files with 10 additions and 8 deletions
|
|
@ -381,11 +381,9 @@ export function ChatSidebar({ formData }: ChatSidebarProps) {
|
|||
setIsLoading(true)
|
||||
|
||||
try {
|
||||
const documentIds: string[] = []
|
||||
|
||||
for (const draft of draftDocs) {
|
||||
const promises = draftDocs.map(async (draft) => {
|
||||
if (draft.kind === "x_research" && xResearchStatus !== "correct") {
|
||||
continue
|
||||
return null
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
@ -397,13 +395,17 @@ export function ChatSidebar({ formData }: ChatSidebarProps) {
|
|||
},
|
||||
})
|
||||
|
||||
if (docResponse.data?.id) {
|
||||
documentIds.push(docResponse.data.id)
|
||||
}
|
||||
return docResponse.data?.id
|
||||
} catch (error) {
|
||||
console.warn("Error creating document:", error)
|
||||
return null
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const results = await Promise.all(promises)
|
||||
const documentIds = results.filter(
|
||||
(id): id is string => id !== null && id !== undefined,
|
||||
)
|
||||
|
||||
if (documentIds.length > 0) {
|
||||
await pollForMemories(documentIds)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue