Fix file tree refresh after convert and compiler sync on set-as-main
Build and Deploy Verso / deploy (push) Successful in 14m4s
Build and Deploy Verso / deploy (push) Successful in 14m4s
- Convert: backend now returns parentFolderId+isNew; frontend calls dispatchCreateDoc directly so the new file appears without a page refresh - Set as main: infer compiler from file extension and POST both rootDocId and compiler together; updateProject propagates the change to the editor settings dropdown and project list immediately Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
b0b389dc4c
commit
065534819c
@@ -1,5 +1,6 @@
|
||||
import { postJSON } from '@/infrastructure/fetch-json'
|
||||
import { useProjectContext } from '@/shared/context/project-context'
|
||||
import { useFileTreeData } from '@/shared/context/file-tree-data-context'
|
||||
import { useCallback, useState } from 'react'
|
||||
import {
|
||||
showExportDocumentError,
|
||||
@@ -12,6 +13,7 @@ export default function useConvertDoc(
|
||||
docId: string | null
|
||||
) {
|
||||
const { projectId } = useProjectContext()
|
||||
const { dispatchCreateDoc } = useFileTreeData()
|
||||
const [converting, setConverting] = useState(false)
|
||||
|
||||
const convert = useCallback(async () => {
|
||||
@@ -19,17 +21,24 @@ export default function useConvertDoc(
|
||||
setConverting(true)
|
||||
hideExportDocumentError()
|
||||
try {
|
||||
await postJSON(`/project/${projectId}/doc/${docId}/convert/${type}`, {
|
||||
body: {},
|
||||
})
|
||||
const result = await postJSON(
|
||||
`/project/${projectId}/doc/${docId}/convert/${type}`,
|
||||
{ body: {} }
|
||||
)
|
||||
showExportDocumentSuccess(type)
|
||||
if (result.isNew) {
|
||||
dispatchCreateDoc(result.parentFolderId, {
|
||||
_id: result.docId,
|
||||
name: result.name,
|
||||
})
|
||||
}
|
||||
} catch (err: any) {
|
||||
const errorMessage = err?.data?.error
|
||||
showExportDocumentError(errorMessage)
|
||||
} finally {
|
||||
setConverting(false)
|
||||
}
|
||||
}, [projectId, docId, type])
|
||||
}, [projectId, docId, type, dispatchCreateDoc])
|
||||
|
||||
return { convert, converting }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user