Skip to content

Commit

Permalink
fix: 🐛 Fail safe on adding all nodes to main
Browse files Browse the repository at this point in the history
  • Loading branch information
SkepticMystic committed Nov 19, 2021
1 parent 690bbb3 commit 8435b5a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
21 changes: 12 additions & 9 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22546,13 +22546,11 @@ class MatrixView extends obsidian.ItemView {
return hierData;
});
debug(settings, { data });
const hierSquares = this.getHierSquares(userHierarchies, data, currFile, settings);
debug(settings, { hierSquares });
const filteredSquaresArr = hierSquares.filter((squareArr) => squareArr.some((square) => square.realItems.length + square.impliedItems.length > 0));
const hierSquares = this.getHierSquares(userHierarchies, data, currFile, settings).filter((squareArr) => squareArr.some((square) => square.realItems.length + square.impliedItems.length > 0));
const compInput = {
target: contentEl,
props: {
filteredSquaresArr,
filteredSquaresArr: hierSquares,
currFile,
settings,
matrixView: this,
Expand Down Expand Up @@ -35427,16 +35425,16 @@ class BCPlugin extends obsidian.Plugin {
return hierarchyNoteItems;
}
// SECTION OneSource
populateGraph(g, currFileName, fieldValues, dir, fieldName) {
populateGraph(g, currFileName, targets, dir, fieldName) {
//@ts-ignore
addNodeIfNot(g, currFileName, { dir, fieldName });
if (fieldName === "")
return;
fieldValues.forEach((value) => {
targets.forEach((target) => {
//@ts-ignore
addNodeIfNot(g, value, { dir, fieldName });
addNodeIfNot(g, target, { dir, fieldName });
//@ts-ignore
addEdgeIfNot(g, currFileName, value, { dir, fieldName });
addEdgeIfNot(g, currFileName, target, { dir, fieldName });
});
}
populateMain(main, currFileName, dir, fieldName, targets, neighbours, neighbourObjArr) {
Expand Down Expand Up @@ -35517,7 +35515,6 @@ class BCPlugin extends obsidian.Plugin {
new obsidian.Notice(`${note} is no longer in your vault. It is best to remove it in Breadcrumbs settings.`);
}
}
debug(settings, { hierarchyNotesArr });
}
debugGroupEnd(settings, "debugMode");
const { userHierarchies } = settings;
Expand Down Expand Up @@ -35619,6 +35616,12 @@ class BCPlugin extends obsidian.Plugin {
debug(settings, "graphs inited");
debug(settings, { graphs });
debugGroupEnd(settings, "debugMode");
files.forEach((file) => {
if (!graphs.main.hasNode(file.basename)) {
console.log(`${file.basename} was not in main`);
graphs.main.addNode(file.basename);
}
});
return graphs;
}
// !SECTION OneSource
Expand Down
7 changes: 2 additions & 5 deletions src/MatrixView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,10 +477,7 @@ export default class MatrixView extends ItemView {
data,
currFile,
settings
);
debug(settings, { hierSquares });

const filteredSquaresArr = hierSquares.filter((squareArr) =>
).filter((squareArr) =>
squareArr.some(
(square) => square.realItems.length + square.impliedItems.length > 0
)
Expand All @@ -489,7 +486,7 @@ export default class MatrixView extends ItemView {
const compInput = {
target: contentEl,
props: {
filteredSquaresArr,
filteredSquaresArr: hierSquares,
currFile,
settings,
matrixView: this,
Expand Down
17 changes: 10 additions & 7 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,19 +333,19 @@ export default class BCPlugin extends Plugin {
populateGraph(
g: Graph,
currFileName: string,
fieldValues: string[],
targets: string[],
dir: Directions,
fieldName: string
): void {
//@ts-ignore
addNodeIfNot(g, currFileName, { dir, fieldName });

if (fieldName === "") return;
fieldValues.forEach((value) => {
targets.forEach((target) => {
//@ts-ignore
addNodeIfNot(g, value, { dir, fieldName });
addNodeIfNot(g, target, { dir, fieldName });
//@ts-ignore
addEdgeIfNot(g, currFileName, value, { dir, fieldName });
addEdgeIfNot(g, currFileName, target, { dir, fieldName });
});
}

Expand Down Expand Up @@ -455,8 +455,6 @@ export default class BCPlugin extends Plugin {
);
}
}

debug(settings, { hierarchyNotesArr });
}
debugGroupEnd(settings, "debugMode");

Expand Down Expand Up @@ -603,7 +601,12 @@ export default class BCPlugin extends Plugin {
debug(settings, { graphs });

debugGroupEnd(settings, "debugMode");

files.forEach((file) => {
if (!graphs.main.hasNode(file.basename)) {
console.log(`${file.basename} was not in main`);
graphs.main.addNode(file.basename);
}
});
return graphs;
}

Expand Down

0 comments on commit 8435b5a

Please sign in to comment.