mirror of
https://github.com/reconurge/flowsint.git
synced 2026-07-18 19:20:13 -05:00
feat(app): fix node positions
This commit is contained in:
@@ -75,7 +75,6 @@ const GraphMain = () => {
|
||||
showIcons={true}
|
||||
onGraphRef={handleGraphRef}
|
||||
allowLasso
|
||||
minimap={false}
|
||||
sketchId={sketchId}
|
||||
/>
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@ interface GraphViewerProps {
|
||||
onGraphRef?: (ref: any) => void
|
||||
instanceId?: string // Add instanceId prop for instance-specific actions
|
||||
allowLasso?: boolean
|
||||
minimap?: boolean
|
||||
sketchId?: string // Add sketchId for saving node positions
|
||||
}
|
||||
|
||||
@@ -150,7 +149,6 @@ const GraphViewer: React.FC<GraphViewerProps> = ({
|
||||
onGraphRef,
|
||||
instanceId,
|
||||
allowLasso = false,
|
||||
minimap = false,
|
||||
sketchId
|
||||
}) => {
|
||||
const [containerSize, setContainerSize] = useState({ width: 0, height: 0 })
|
||||
@@ -181,7 +179,6 @@ const GraphViewer: React.FC<GraphViewerProps> = ({
|
||||
// Store selectors
|
||||
const nodeColors = useNodesDisplaySettings((s) => s.colors)
|
||||
const getSize = useNodesDisplaySettings((s) => s.getSize)
|
||||
const view = useGraphControls((s) => s.view)
|
||||
|
||||
// Get settings by categories to avoid re-renders
|
||||
const forceSettings = useGraphSettingsStore((s) => s.forceSettings)
|
||||
|
||||
@@ -2,6 +2,7 @@ import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { useDebounce } from './use-debounce'
|
||||
import { sketchService } from '@/api/sketch-service'
|
||||
import { useGraphSaveStatus } from '@/stores/graph-save-status-store'
|
||||
import { useGraphStore } from '@/stores/graph-store'
|
||||
|
||||
interface NodePosition {
|
||||
x: number
|
||||
@@ -16,6 +17,7 @@ export type SaveStatus = 'idle' | 'pending' | 'saving' | 'saved' | 'error'
|
||||
*/
|
||||
export function useSaveNodePositions(sketchId?: string) {
|
||||
const [changedNodePositions, setChangedNodePositions] = useState<Map<string, NodePosition>>(new Map())
|
||||
const setNodes = useGraphStore(s => s.setNodes)
|
||||
const isStabilizingRef = useRef(false) // Start as false, mark as true only during layout regeneration
|
||||
const setSaveStatus = useGraphSaveStatus((state) => state.setSaveStatus)
|
||||
|
||||
@@ -68,6 +70,7 @@ export function useSaveNodePositions(sketchId?: string) {
|
||||
|
||||
if (newMap.size > 0) {
|
||||
setChangedNodePositions(newMap)
|
||||
setNodes(nodes)
|
||||
setSaveStatus('pending')
|
||||
}
|
||||
}, [sketchId])
|
||||
|
||||
Reference in New Issue
Block a user