refactor: remove unused setError parameter from mermaid components

Clean up code by removing unnecessary setError parameter that was not being used effectively. This simplifies the component interfaces and reduces potential error handling confusion.
This commit is contained in:
icarus 2025-10-22 18:56:29 +08:00
parent 552694df11
commit c455b0a70a
3 changed files with 3 additions and 6 deletions

View File

@ -271,7 +271,6 @@ export const CodeBlockView: React.FC<Props> = memo(({ children: code, language,
error,
content: code
},
setError,
onSave,
setTools
})

View File

@ -26,7 +26,6 @@ interface UseMermaidFixTool {
content: string
}
onSave: (newContent: string) => Promise<void>
setError: (error: unknown) => void
setTools: React.Dispatch<React.SetStateAction<ActionTool[]>>
}
@ -73,7 +72,7 @@ Example outputs:
`
export const useMermaidFixTool = ({ enabled, context, onSave, setError, setTools }: UseMermaidFixTool) => {
export const useMermaidFixTool = ({ enabled, context, onSave, setTools }: UseMermaidFixTool) => {
const { t } = useTranslation()
const { registerTool, removeTool } = useToolManager(setTools)
const { language } = useSettings()
@ -140,7 +139,6 @@ export const useMermaidFixTool = ({ enabled, context, onSave, setError, setTools
const validResult = parsedResult.data
if (validResult.fixed) {
await onSave(validResult.result)
setError(undefined)
} else {
window.toast.warning({ title: t('code_block.mermaid_fix.failed'), description: validResult.reason })
}
@ -153,7 +151,7 @@ export const useMermaidFixTool = ({ enabled, context, onSave, setError, setTools
}
setPending(blockId, false)
}, [setPending, blockId, completion, prompt, t, onSave, setError])
}, [setPending, blockId, completion, prompt, t, onSave])
// when unmounted
useEffect(() => {

View File

@ -124,7 +124,7 @@ const MermaidPreview = ({
const error = mermaidError || renderError
useEffect(() => {
if (error !== undefined && error !== null && onError !== undefined) {
if (onError !== undefined) {
onError(error)
}
}, [error, onError])