From 72037a1865f6d4c87b1d21bd8f3ab391bfe68585 Mon Sep 17 00:00:00 2001 From: hjlarry Date: Thu, 21 Aug 2025 14:27:41 +0800 Subject: [PATCH] improve cursors logic --- .../workflow-app/components/workflow-main.tsx | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/web/app/components/workflow-app/components/workflow-main.tsx b/web/app/components/workflow-app/components/workflow-main.tsx index f7b9264384..d310d0383c 100644 --- a/web/app/components/workflow-app/components/workflow-main.tsx +++ b/web/app/components/workflow-app/components/workflow-main.tsx @@ -41,7 +41,17 @@ const WorkflowMain = ({ const containerRef = useRef(null) const store = useStoreApi() - const { startCursorTracking, stopCursorTracking, onlineUsers } = useCollaboration(appId, store) + const { startCursorTracking, stopCursorTracking, onlineUsers, cursors, isConnected } = useCollaboration(appId, store) + const [myUserId, setMyUserId] = useState(null) + + useEffect(() => { + if (isConnected) + setMyUserId('current-user') + }, [isConnected]) + + const filteredCursors = Object.fromEntries( + Object.entries(cursors).filter(([userId]) => userId !== myUserId), + ) useEffect(() => { if (containerRef.current) @@ -133,18 +143,6 @@ const WorkflowMain = ({ handleWorkflowStartRunInWorkflow, } = useWorkflowStartRun() - const { cursors, isConnected } = useCollaboration(appId) - const [myUserId, setMyUserId] = useState(null) - - useEffect(() => { - if (isConnected) - setMyUserId('current-user') - }, [isConnected]) - - const filteredCursors = Object.fromEntries( - Object.entries(cursors).filter(([userId]) => userId !== myUserId), - ) - const { fetchInspectVars } = useSetWorkflowVarsWithValue({ flowId: appId, ...useConfigsMap(),