diff --git a/app/src/pages/mapping_page/components/MainPanel/components/EntityNode.tsx b/app/src/pages/mapping_page/components/MainPanel/components/EntityNode.tsx index e94d8cb..cf04f98 100644 --- a/app/src/pages/mapping_page/components/MainPanel/components/EntityNode.tsx +++ b/app/src/pages/mapping_page/components/MainPanel/components/EntityNode.tsx @@ -5,37 +5,34 @@ import { EntityNodeType } from '@/pages/mapping_page/components/MainPanel/types' import useMappingPage from '@/pages/mapping_page/state'; import { Card, HTMLTable, Icon } from '@blueprintjs/core'; import { NodeProps } from '@xyflow/react'; -import { useEffect, useState } from 'react'; +import { useMemo } from 'react'; export function EntityNode({ data, selected }: NodeProps) { const ontologies = useMappingPage(state => state.ontologies); - const [properties, setProperties] = useState([]); + const properties = useMemo(() => { + if (!ontologies) return []; - useEffect(() => { - if (ontologies) { - const allProperties = ontologies.flatMap(ontology => ontology.properties); - const _properties = data.properties.map(property_1 => { - const _property = allProperties.find( - property_2 => property_2.full_uri === property_1, - ); - return ( - _property ?? - ({ - type: 'property', - belongs_to: 'Created', - description: [], - domain: [], - full_uri: property_1, - label: [], - property_type: 'any', - range: [], - is_deprecated: false, - } as Property) - ); - }); - setProperties(_properties); - } + const allProperties = ontologies.flatMap(ontology => ontology.properties); + return data.properties.map(property_1 => { + const _property = allProperties.find( + property_2 => property_2.full_uri === property_1, + ); + return ( + _property ?? + ({ + type: 'property', + belongs_to: 'Created', + description: [], + domain: [], + full_uri: property_1, + label: [], + property_type: 'any', + range: [], + is_deprecated: false, + } as Property) + ); + }); }, [ontologies, data.properties]); return ( diff --git a/app/src/pages/mapping_page/components/MainPanel/components/FloatingEdge.tsx b/app/src/pages/mapping_page/components/MainPanel/components/FloatingEdge.tsx index 3673fd6..c3acdc6 100644 --- a/app/src/pages/mapping_page/components/MainPanel/components/FloatingEdge.tsx +++ b/app/src/pages/mapping_page/components/MainPanel/components/FloatingEdge.tsx @@ -1,6 +1,7 @@ import { getEdgePosition } from '@/pages/mapping_page/components/MainPanel/utils'; import { EdgeProps, getSmoothStepPath, useInternalNode } from '@xyflow/react'; +import { useMemo } from 'react'; import './styles.scss'; function FloatingEdge({ @@ -16,28 +17,30 @@ function FloatingEdge({ const sourceNode = useInternalNode(source); const targetNode = useInternalNode(target); - if (!sourceNode || !targetNode) { - return null; - } + const [edgePath] = useMemo(() => { + if (!sourceNode || !targetNode) { + return []; + } - const { sx, sy, sp, tx, ty, tp, cx, cy } = getEdgePosition( - sourceNode, - sourceHandleId ?? '', - targetNode, - targetHandleId ?? '', - ); + const { sx, sy, sp, tx, ty, tp, cx, cy } = getEdgePosition( + sourceNode, + sourceHandleId ?? '', + targetNode, + targetHandleId ?? '', + ); - const [edgePath] = getSmoothStepPath({ - sourceX: sx, - sourceY: sy, - sourcePosition: sp, - targetX: tx, - targetY: ty, - targetPosition: tp, - borderRadius: 10, - centerX: cx, - centerY: cy, - }); + return getSmoothStepPath({ + sourceX: sx, + sourceY: sy, + sourcePosition: sp, + targetX: tx, + targetY: ty, + targetPosition: tp, + borderRadius: 10, + centerX: cx, + centerY: cy, + }); + }, [sourceHandleId, sourceNode, targetHandleId, targetNode]); return ( { }, }); }, - // Reason: we only want to update the node when the node id or reactflow changes - // eslint-disable-next-line react-hooks/exhaustive-deps - [node.id, reactflow], + [node, reactflow], ); const createNewClassItemFromQuery = (query: string) => { diff --git a/app/src/pages/mapping_page/components/NodeProperties/components/URIRefProperties.tsx b/app/src/pages/mapping_page/components/NodeProperties/components/URIRefProperties.tsx index 6dea366..587972d 100644 --- a/app/src/pages/mapping_page/components/NodeProperties/components/URIRefProperties.tsx +++ b/app/src/pages/mapping_page/components/NodeProperties/components/URIRefProperties.tsx @@ -21,8 +21,7 @@ const URIRefProperties = ({ node }: { node: URIRefNodeType }) => { }, }); }, - // eslint-disable-next-line react-hooks/exhaustive-deps - [node.id, reactflow], + [node, reactflow], ); return ( diff --git a/app/src/pages/mapping_page/hooks/useRangeOrderer.ts b/app/src/pages/mapping_page/hooks/useRangeOrderer.ts deleted file mode 100644 index 8ddf623..0000000 --- a/app/src/pages/mapping_page/hooks/useRangeOrderer.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { Property } from '@/lib/api/ontology_api/types'; -import { - EntityNodeType, - XYNodeTypes, -} from '@/pages/mapping_page/components/MainPanel/types'; -import useMappingPage from '@/pages/mapping_page/state'; -import { useNodes } from '@xyflow/react'; -import { useEffect, useState } from 'react'; - -export default function useRangeOrderer(node: EntityNodeType) { - const [predicates, setPredicates] = useState< - (Property & { group: string })[] - >([]); - const ontologies = useMappingPage(state => state.ontologies); - const nodes = useNodes(); - - useEffect(() => { - - - }, [node, nodes, ontologies]); - - return predicates; -} diff --git a/server/services/local/local_fs_service.py b/server/services/local/local_fs_service.py index 1a989b9..a7c8c3a 100644 --- a/server/services/local/local_fs_service.py +++ b/server/services/local/local_fs_service.py @@ -135,7 +135,7 @@ def download_file_with_uuid(self, uuid: str) -> bytes: code=ErrCodes.FILE_NOT_FOUND, ) - table_hash = res.tuple()[0].hash + # table_hash = res.tuple()[0].hash file_path = self._FILE_DIR / uuid # if ( # table_hash