feat(app): fix node positions

This commit is contained in:
dextmorgn
2025-11-17 00:21:01 +01:00
parent eead6a1018
commit 4e9c17d98e
3 changed files with 3 additions and 4 deletions

View File

@@ -75,7 +75,6 @@ const GraphMain = () => {
showIcons={true}
onGraphRef={handleGraphRef}
allowLasso
minimap={false}
sketchId={sketchId}
/>

View File

@@ -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)

View File

@@ -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])