Skip to content

Commit

Permalink
Check if any parents, siblings, or children
Browse files Browse the repository at this point in the history
  • Loading branch information
SkepticMystic committed Jun 21, 2021
1 parent acfc132 commit 4433697
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "breadcrumbs",
"name": "Breadcrumbs",
"version": "0.2.2",
"version": "0.2.3",
"minAppVersion": "0.12.5",
"description": "Visualise the hierarchy of your vault using a breadcrumb trail",
"author": "SkepticMystic",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "breadcrumbs-plugin",
"version": "0.2.2",
"version": "0.2.3",
"description": "Visualise the hierarchy of your vault using a breadcrumb trail",
"main": "main.js",
"scripts": {
Expand Down
37 changes: 23 additions & 14 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,21 @@ class BreadcrumbsView extends ItemView {
gSiblings.setNode(currFileName, neighbourObj.current);
gChildren.setNode(currFileName, neighbourObj.current);

neighbourObj.parents.forEach((parent) =>
gParents.setEdge(currFileName, parent, "parent")
);

neighbourObj.siblings.forEach((sibling) =>
gSiblings.setEdge(currFileName, sibling, "sibling")
);

neighbourObj.children.forEach((child) =>
gChildren.setEdge(currFileName, child, "child")
);
if (neighbourObj.parents) {
neighbourObj.parents.forEach((parent) =>
gParents.setEdge(currFileName, parent, "parent")
);
}
if (neighbourObj.siblings) {
neighbourObj.siblings.forEach((sibling) =>
gSiblings.setEdge(currFileName, sibling, "sibling")
);
}
if (neighbourObj.children) {
neighbourObj.children.forEach((child) =>
gChildren.setEdge(currFileName, child, "child")
);
}
});

return { gParents, gSiblings, gChildren };
Expand Down Expand Up @@ -291,13 +295,18 @@ class BreadcrumbsView extends ItemView {

/// Implied Siblings
const currParents = gParents.successors(currFile.basename) ?? [];
const indexCurrFile = currParents.indexOf(currFile.basename);
let currParentsNotCurrFile = currParents;
if (indexCurrFile >= 0) {
currParentsNotCurrFile = currParents.splice(indexCurrFile, 1);
}
const impliedSiblings: string[] = [];
if (currParents.length) {
currParents.forEach((parent) =>
if (currParentsNotCurrFile.length) {
currParentsNotCurrFile.forEach((parent) =>
impliedSiblings.push(gParents.predecessors(parent) ?? [])
);
}
const flatImpliedSiblings = impliedSiblings.flat()
const flatImpliedSiblings = impliedSiblings.flat();
if (flatImpliedSiblings.length) {
rightDiv.createDiv({ text: "Implied" });
flatImpliedSiblings.forEach((item: string, i) => {
Expand Down
1 change: 1 addition & 0 deletions versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"0.2.3": "0.12.5",
"0.2.2": "0.12.5",
"0.2.1": "0.12.5",
"0.2.0": "0.12.5",
Expand Down

0 comments on commit 4433697

Please sign in to comment.