mirror of
https://github.com/stackrender/stackrender.git
synced 2026-09-11 03:35:42 +00:00
Improved Performence , Re-Order Diagram whene import , Fix Database History Bug (stuck in undo or redo , foriegn keys constraint error)
This commit is contained in:
@@ -4,15 +4,14 @@ import { Node, useReactFlow } from "@xyflow/react";
|
||||
import { useEffect } from "react";
|
||||
import { getDefaultTableOverlapping } from "@/utils/tables";
|
||||
import hash from "object-hash";
|
||||
import { useDatabase } from "@/providers/database-provider/database-provider";
|
||||
|
||||
|
||||
|
||||
export const useTableToNode = (tables: TableType[]): void => {
|
||||
const { setNodes } = useReactFlow();
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
const tableNodes = tables.map((table: TableType) => {
|
||||
return {
|
||||
id: table.id,
|
||||
@@ -31,21 +30,23 @@ export const useTableToNode = (tables: TableType[]): void => {
|
||||
width: 224
|
||||
}
|
||||
} as Node
|
||||
})
|
||||
|
||||
}) ;
|
||||
|
||||
setNodes((nodes) => {
|
||||
return tableNodes.map((tableNode) => {
|
||||
const node: Node | undefined = nodes.find((node: Node) => node.id == tableNode.id);
|
||||
|
||||
if (!node)
|
||||
return tableNode;
|
||||
else {
|
||||
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