Skip to content

Commit

Permalink
fix(Hierarchy Note): 🐛 Don't push children if !noteUp
Browse files Browse the repository at this point in the history
  • Loading branch information
SkepticMystic committed Aug 20, 2021
1 parent 970bdf5 commit 841f7bf
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,11 @@ export default class BreadcrumbsPlugin extends Plugin {
return null;
}

hierarchyNoteAdjList(str: string) {
hierarchyNoteAdjList = (str: string) => {
const layers = str.split("\n");
console.log({ layers });

const depth = (line: string) => line.split("-")[0].length;
const depths = layers.map(depth);

const hier: { note: string; depth: number; children: string[] }[] = [];

const lineRegex = new RegExp(/\s*- \[\[(.*)\]\]/);
Expand Down Expand Up @@ -346,14 +346,17 @@ export default class BreadcrumbsPlugin extends Plugin {
if (noteUp) {
hier[hier.indexOf(noteUp)].children.push(currNote);
}
} else if (currDepth === 0) {
} else {
const copy = [...hier];
const noteUp = copy.reverse().find((adjItem, i) => {
debug(this.settings, { i, currNote, currDepth });
return adjItem.depth === currDepth - 1;
});
debug(this.settings, { noteUp });
hier[hier.indexOf(noteUp)].children.push(currNote);
if (noteUp) {
hier[hier.indexOf(noteUp)].children.push(currNote);
}
}
} else {
const prevLine = layers[lineNo - 1];
Expand All @@ -374,7 +377,7 @@ export default class BreadcrumbsPlugin extends Plugin {
item.children = removeDuplicates(item.children);
});
return hier;
}
};

// SECTION OneSource

Expand Down Expand Up @@ -467,7 +470,7 @@ export default class BreadcrumbsPlugin extends Plugin {
const g = graphs.hierGs.find(
(hierG) => hierG.down[hierarchyNoteFieldName]
).down[hierarchyNoteFieldName];

hierarchyNotesArr.forEach((adjListItem) => {
adjListItem.children.forEach((child) => {
g.setEdge(adjListItem.note, child, {
Expand Down

0 comments on commit 841f7bf

Please sign in to comment.