mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-27 12:51:26 +08:00
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:
parent
552694df11
commit
c455b0a70a
@ -271,7 +271,6 @@ export const CodeBlockView: React.FC<Props> = memo(({ children: code, language,
|
||||
error,
|
||||
content: code
|
||||
},
|
||||
setError,
|
||||
onSave,
|
||||
setTools
|
||||
})
|
||||
|
||||
@ -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(() => {
|
||||
|
||||
@ -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])
|
||||
|
||||
Loading…
Reference in New Issue
Block a user