chore: Cleanup flowDB

This commit is contained in:
Sidharth Vinod
2024-06-28 21:50:33 +05:30
parent 69538aad09
commit 02ef40223c

View File

@@ -729,14 +729,12 @@ export const destructLink = (_str: string, _startStr: string) => {
// Todo optimizer this by caching existing nodes
const exists = (allSgs: FlowSubGraph[], _id: string) => {
let res = false;
allSgs.forEach((sg) => {
const pos = sg.nodes.indexOf(_id);
if (pos >= 0) {
res = true;
for (const sg of allSgs) {
if (sg.nodes.indexOf(_id) >= 0) {
return true;
}
});
return res;
}
return false;
};
/**
* Deletes an id from all subgraphs
@@ -830,14 +828,11 @@ function getCompiledStyles(classDefs: string[]) {
let compiledStyles: string[] = [];
for (const customClass of classDefs) {
const cssClass = classes.get(customClass);
// log.debug('IPI cssClass in flowDb', cssClass);
if (cssClass) {
if (cssClass.styles) {
compiledStyles = [...compiledStyles, ...(cssClass.styles ?? [])].map((s) => s.trim());
}
if (cssClass.textStyles) {
compiledStyles = [...compiledStyles, ...(cssClass.textStyles ?? [])].map((s) => s.trim());
}
if (cssClass?.styles) {
compiledStyles = [...compiledStyles, ...(cssClass.styles ?? [])].map((s) => s.trim());
}
if (cssClass?.textStyles) {
compiledStyles = [...compiledStyles, ...(cssClass.textStyles ?? [])].map((s) => s.trim());
}
}
return compiledStyles;
@@ -858,9 +853,9 @@ export const getData = () => {
if (subGraph.nodes.length > 0) {
subGraphDB.set(subGraph.id, true);
}
subGraph.nodes.forEach((id) => {
for (const id of subGraph.nodes) {
parentDB.set(id, subGraph.id);
});
}
}
// Data is setup, add the nodes
@@ -917,8 +912,6 @@ export const getData = () => {
edges.push(edge);
});
// log.debug('IPI nodes', JSON.stringify(nodes, null, 2));
return { nodes, edges, other: {}, config };
};