feat: Implement document saving with reindexing

- Updated the document saving endpoint to trigger reindexing after saving.
- Introduced a new Celery task for reindexing documents.
- Refactored the editor page to reflect the changes in the API endpoint and method.
This commit is contained in:
Anish Sarkar 2025-11-30 04:08:12 +05:30
parent 91bc344b56
commit f8e4926969
4 changed files with 156 additions and 83 deletions

View file

@ -112,11 +112,11 @@ export default function EditorPage() {
setSaving(true);
try {
// Save blocknote_document to database (without finalizing/reindexing)
// Save blocknote_document and trigger reindexing in background
const response = await fetch(
`${process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL}/api/v1/documents/${documentId}/blocknote-content`,
`${process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL}/api/v1/documents/${documentId}/save`,
{
method: "PUT",
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${token}`,
@ -133,7 +133,7 @@ export default function EditorPage() {
}
setHasUnsavedChanges(false);
toast.success("Document saved successfully");
toast.success("Document saved! Reindexing in background...");
// Small delay before redirect to show success message
setTimeout(() => {