Fix refresh layout button failure
This commit is contained in:
@@ -8,7 +8,9 @@ import Input from '@/components/ui/Input'
|
||||
import { controlButtonVariant } from '@/lib/constants'
|
||||
import { useSettingsStore } from '@/stores/settings'
|
||||
import { useBackendState } from '@/stores/state'
|
||||
import { useGraphStore } from '@/stores/graph'
|
||||
import { useSigma } from '@react-sigma/core'
|
||||
import { useLayoutForceAtlas2 } from '@react-sigma/layout-forceatlas2'
|
||||
import { animateNodes } from 'sigma/utils'
|
||||
|
||||
import { SettingsIcon, RefreshCwIcon } from 'lucide-react'
|
||||
import { useTranslation } from 'react-i18next';
|
||||
@@ -115,7 +117,16 @@ const LabeledNumberInput = ({
|
||||
export default function Settings() {
|
||||
const [opened, setOpened] = useState<boolean>(false)
|
||||
const [tempApiKey, setTempApiKey] = useState<string>('')
|
||||
const refreshLayout = useGraphStore.use.refreshLayout()
|
||||
const sigma = useSigma()
|
||||
const maxIterations = useSettingsStore.use.graphLayoutMaxIterations()
|
||||
const layout = useLayoutForceAtlas2({ iterations: maxIterations })
|
||||
|
||||
const refreshLayout = useCallback(() => {
|
||||
if (!sigma) return
|
||||
const graph = sigma.getGraph()
|
||||
const positions = layout.positions()
|
||||
animateNodes(graph, positions, { duration: 500 })
|
||||
}, [sigma, layout])
|
||||
|
||||
const showPropertyPanel = useSettingsStore.use.showPropertyPanel()
|
||||
const showNodeSearchBar = useSettingsStore.use.showNodeSearchBar()
|
||||
|
Reference in New Issue
Block a user