From ebc3e97c9fdaabfc4fcd9c35525f302ad3a8cb45 Mon Sep 17 00:00:00 2001 From: Kirill Rogovoy Date: Sun, 25 Jul 2021 14:38:05 +0300 Subject: Move showTweaks to tweaks.tsx --- pages/index.tsx | 51 ++++++++++++++++----------------------------------- 1 file changed, 16 insertions(+), 35 deletions(-) (limited to 'pages/index.tsx') diff --git a/pages/index.tsx b/pages/index.tsx index d39db81..ded8a1c 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -12,12 +12,7 @@ import { GraphData, NodeObject } from 'force-graph' import { useWindowSize } from '@react-hook/window-size' import { useAnimation } from '@lilib/hooks' -import { - Button, - Box, - IconButton, - useTheme, -} from '@chakra-ui/react' +import { Button, Box, IconButton, useTheme } from '@chakra-ui/react' import { SettingsIcon } from '@chakra-ui/icons' import { initialPhysics, initialFilter } from '../components/config' @@ -59,15 +54,13 @@ export default function Home() { export function GraphPage() { const [physics, setPhysics] = usePersistantState('physics', initialPhysics) const [filter, setFilter] = usePersistantState('filter', initialFilter) - // const [theme, setTheme] = useState(initialTheme) const [graphData, setGraphData] = useState(null) const [emacsNodeId, setEmacsNodeId] = useState(null) const nodeByIdRef = useRef({}) - const parentNodesByFileRef = useRef({}) //useRef({}) const linksByNodeIdRef = useRef({}) - const updateGraphData = () => { + const fetchGraphData = () => { return fetch('http://localhost:35901/graph') .then((res) => res.json()) .then((orgRoamGraphData: OrgRoamGraphReponse) => { @@ -95,18 +88,17 @@ export function GraphPage() { const emacsNodeId = e.data setEmacsNodeId(emacsNodeId) }) - updateGraphData() + fetchGraphData() }, []) useEffect(() => { if (!emacsNodeId) { return } - updateGraphData() + fetchGraphData() }, [emacsNodeId]) const [threeDim, setThreeDim] = useState(false) - const [showTweaks, setShowTweaks] = useState(true) if (!graphData) { return null @@ -114,29 +106,17 @@ export function GraphPage() { return ( - {showTweaks ? ( - { - setShowTweaks(false) - }} - /> - ) : ( - - } - onClick={() => setShowTweaks(true)} - /> - - )} + + +