mirror of
https://github.com/langgenius/dify.git
synced 2026-11-13 14:51:39 +08:00
Co-authored-by: QuantumGhost <obelisk.reg+git@gmail.com> Co-authored-by: yyh <yuanyouhuilyz@gmail.com>
25 lines
673 B
TypeScript
25 lines
673 B
TypeScript
import type { useNodesSyncDraft } from '@/app/components/workflow/hooks/use-nodes-sync-draft'
|
|
|
|
export class HumanInputDraftSyncError extends Error {
|
|
constructor() {
|
|
super('Human Input draft could not be saved')
|
|
this.name = 'HumanInputDraftSyncError'
|
|
}
|
|
}
|
|
|
|
export const syncHumanInputDraft = async (
|
|
syncDraft: ReturnType<typeof useNodesSyncDraft>['doSyncWorkflowDraft'],
|
|
): Promise<void> => {
|
|
let saved = false
|
|
let failed = false
|
|
const result = await syncDraft(true, {
|
|
onSuccess: () => {
|
|
saved = true
|
|
},
|
|
onError: () => {
|
|
failed = true
|
|
},
|
|
})
|
|
if (failed || (!saved && result == null)) throw new HumanInputDraftSyncError()
|
|
}
|