From 28e813f57f41c8633c1b292617c19168f26e657d Mon Sep 17 00:00:00 2001 From: StyleZhang Date: Wed, 3 Apr 2024 14:37:51 +0800 Subject: [PATCH] fix --- web/app/components/workflow/index.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/web/app/components/workflow/index.tsx b/web/app/components/workflow/index.tsx index 64e43fa74f..d6b4c52cc6 100644 --- a/web/app/components/workflow/index.tsx +++ b/web/app/components/workflow/index.tsx @@ -5,11 +5,14 @@ import { memo, useCallback, useEffect, + useLayoutEffect, useMemo, } from 'react' import { useParams } from 'next/navigation' import { setAutoFreeze } from 'immer' -import { useKeyPress } from 'ahooks' +import { + useKeyPress, +} from 'ahooks' import ReactFlow, { Background, ReactFlowProvider, @@ -48,6 +51,7 @@ import { import Loading from '@/app/components/base/loading' import { FeaturesProvider } from '@/app/components/base/features' import type { Features as FeaturesData } from '@/app/components/base/features/types' +import { useStore as useAppStore } from '@/app/components/app/store' const nodeTypes = { custom: CustomNode, @@ -84,10 +88,13 @@ const Workflow: FC = memo(({ } }, []) - useEffect(() => { + useLayoutEffect(() => { const appId = params.appId return () => { - handleSyncWorkflowDraft(true, appId as string) + const appIdParams = useAppStore.getState().appDetail?.id + + if (appId !== appIdParams) + handleSyncWorkflowDraft(true, appId as string) } }, [])