Skip to content

Commit

Permalink
fix(CSV Crumbs): 🐛 Fix CSV crumbs
Browse files Browse the repository at this point in the history
  • Loading branch information
SkepticMystic committed Nov 19, 2021
1 parent f49a25e commit 08a3fab
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
12 changes: 6 additions & 6 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -35219,9 +35219,9 @@ class BCPlugin extends obsidian.Plugin {
async getCSVRows() {
const { CSVPaths } = this.settings;
const CSVRows = [];
if (CSVPaths[0] === "")
if (CSVPaths === "")
return CSVRows;
const fullPath = obsidian.normalizePath(CSVPaths[0]);
const fullPath = obsidian.normalizePath(CSVPaths);
const content = await this.app.vault.adapter.read(fullPath);
const lines = content.split("\n");
const headers = lines[0].split(",").map((head) => head.trim());
Expand All @@ -35244,7 +35244,7 @@ class BCPlugin extends obsidian.Plugin {
if (fieldName === "" || !row[fieldName])
return;
addNodeIfNot(g, row[fieldName]);
g.addEdge(row.file, row[fieldName], { dir, fieldName });
addEdgeIfNot(g, row.file, row[fieldName], { dir, fieldName });
});
}
async initGraphs() {
Expand Down Expand Up @@ -35329,8 +35329,10 @@ class BCPlugin extends obsidian.Plugin {
fieldName,
});
});
if (useCSV)
if (useCSV) {
this.addCSVCrumbs(g, CSVRows, dir, fieldName);
this.addCSVCrumbs(graphs.main, CSVRows, dir, fieldName);
}
}
});
});
Expand Down Expand Up @@ -35392,8 +35394,6 @@ class BCPlugin extends obsidian.Plugin {
debug(settings, "graphs inited");
debug(settings, { graphs });
debugGroupEnd(settings, "debugMode");
const hierGInfo = [];
iterateAllGs(graphs.hierGs, (g, dir, fieldName) => hierGInfo.push(g.edges().length));
return graphs;
}
// !SECTION OneSource
Expand Down
15 changes: 7 additions & 8 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,9 @@ export default class BCPlugin extends Plugin {
async getCSVRows() {
const { CSVPaths } = this.settings;
const CSVRows: { [key: string]: string }[] = [];
if (CSVPaths[0] === "") return CSVRows;
if (CSVPaths === "") return CSVRows;

const fullPath = normalizePath(CSVPaths[0]);
const fullPath = normalizePath(CSVPaths);

const content = await this.app.vault.adapter.read(fullPath);
const lines = content.split("\n");
Expand Down Expand Up @@ -410,7 +410,7 @@ export default class BCPlugin extends Plugin {
if (fieldName === "" || !row[fieldName]) return;

addNodeIfNot(g, row[fieldName]);
g.addEdge(row.file, row[fieldName], { dir, fieldName });
addEdgeIfNot(g, row.file, row[fieldName], { dir, fieldName });
});
}

Expand Down Expand Up @@ -521,7 +521,10 @@ export default class BCPlugin extends Plugin {
});
});

if (useCSV) this.addCSVCrumbs(g, CSVRows, dir, fieldName);
if (useCSV) {
this.addCSVCrumbs(g, CSVRows, dir, fieldName);
this.addCSVCrumbs(graphs.main, CSVRows, dir, fieldName);
}
}
});
});
Expand Down Expand Up @@ -610,10 +613,6 @@ export default class BCPlugin extends Plugin {

debugGroupEnd(settings, "debugMode");

const hierGInfo = [];
iterateAllGs(graphs.hierGs, (g, dir, fieldName) =>
hierGInfo.push(g.edges().length)
);
return graphs;
}

Expand Down

0 comments on commit 08a3fab

Please sign in to comment.