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:
KarimTamani
2025-07-03 22:01:12 +01:00
parent 815845e1e9
commit 9ecc2f9d56
50 changed files with 982 additions and 549 deletions
+9 -8
View File
@@ -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])
}