mirror of
https://github.com/stackrender/stackrender.git
synced 2026-09-11 03:35:42 +00:00
Obsidian theme developed
This commit is contained in:
@@ -70,7 +70,11 @@ const useHighlightedEdges = (nodes: Node[], relationships: RelationshipType[], e
|
||||
(edge.animated || edge.selected) &&
|
||||
(edge.source === node.id || edge.target === node.id)
|
||||
);
|
||||
const newHighlightedEdgeIds = newHighlightedEdges.map((edge : Edge) => edge.id) ;
|
||||
const previousHighlightedEdgeIds = node.data.highlightedEdges.map((edge : Edge) => edge.id) ;
|
||||
|
||||
if (areArraysEqual(previousHighlightedEdgeIds , newHighlightedEdgeIds))
|
||||
return node ;
|
||||
// Add the highlighted edges to the node's data
|
||||
return {
|
||||
...node,
|
||||
|
||||
@@ -3,13 +3,15 @@ import { TableType } from "@/lib/schemas/table-schema";
|
||||
import { Node, useReactFlow } from "@xyflow/react";
|
||||
import { useEffect } from "react";
|
||||
import { getDefaultTableOverlapping } from "@/utils/tables";
|
||||
import hash from "object-hash";
|
||||
import { compare } from "fast-json-patch";
|
||||
export const useTableToNode = (tables: TableType[]): void => {
|
||||
const { setNodes } = useReactFlow();
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
const nodes = tables.map((table: TableType) => {
|
||||
const tableNodes = tables.map((table: TableType) => {
|
||||
return {
|
||||
id: table.id,
|
||||
type: "table",
|
||||
@@ -29,7 +31,30 @@ export const useTableToNode = (tables: TableType[]): void => {
|
||||
} as Node
|
||||
})
|
||||
|
||||
setNodes(nodes);
|
||||
setNodes((nodes) => {
|
||||
|
||||
return tableNodes.map((tableNode) => {
|
||||
const node: Node | undefined = nodes.find((node: Node) => node.id == tableNode.id);
|
||||
if (!node)
|
||||
return tableNode;
|
||||
else {
|
||||
// const diff = compare(node.data.table as TableType, tableNode.data.table as TableType);
|
||||
|
||||
|
||||
//console.log (diff)
|
||||
|
||||
const hashNode: string = hash(node.data.table as TableType);
|
||||
const hashTableNode: string = hash(tableNode.data.table as TableType);
|
||||
|
||||
|
||||
|
||||
return hashNode == hashTableNode ? node : tableNode;
|
||||
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
});
|
||||
}, [tables])
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user