Skip to content

Commit

Permalink
fix(Hierarchy Note): 🐛 Don't merge all HNs, rather do one at a time (Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
SkepticMystic committed Dec 16, 2021
1 parent c54bb57 commit b3bba6d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 36 deletions.
30 changes: 13 additions & 17 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -51925,33 +51925,32 @@ class BCPlugin extends require$$0.Plugin {
db.end2G({ filteredLinks });
return filteredLinks;
}
addHNsToGraph(hierarchyNotesArr, mainG) {
addHNsToGraph(hnArr, mainG) {
const { HNUpField, userHiers } = this.settings;
const upFields = getFields(userHiers, "up");
hierarchyNotesArr.forEach((hnItem, i) => {
hnArr.forEach((hnItem, i) => {
var _a, _b;
const { note, field, parent } = hnItem;
const upField = field !== null && field !== void 0 ? field : (HNUpField || upFields[0]);
const downField = (_a = getOppFields(userHiers, upField)[0]) !== null && _a !== void 0 ? _a : `${upField}<down>`;
const downField = (_a = getOppFields(userHiers, upField)[0]) !== null && _a !== void 0 ? _a : fallbackOppField(upField, "up");
if (parent === null) {
const s = note;
const t = (_b = hierarchyNotesArr[i + 1]) === null || _b === void 0 ? void 0 : _b.note;
const t = (_b = hnArr[i + 1]) === null || _b === void 0 ? void 0 : _b.note;
addNodesIfNot(mainG, [s, t]);
addEdgeIfNot(mainG, s, t, { dir: "down", field: downField });
}
else {
const aUp = {
addNodesIfNot(mainG, [note, parent]);
addEdgeIfNot(mainG, note, parent, {
dir: "up",
field: upField,
};
addNodesIfNot(mainG, [note, parent]);
addEdgeIfNot(mainG, note, parent, aUp);
const aDown = {
});
// I don't think this needs to be done if the reverse is done above
addNodesIfNot(mainG, [parent, note]);
addEdgeIfNot(mainG, parent, note, {
dir: "down",
field: downField,
};
addNodesIfNot(mainG, [parent, note]);
addEdgeIfNot(mainG, parent, note, aDown);
});
}
});
}
Expand Down Expand Up @@ -52215,21 +52214,18 @@ class BCPlugin extends require$$0.Plugin {
// !SECTION Juggl Links
// SECTION Hierarchy Notes
db.start2G("Hierarchy Notes");
const hierarchyNotesArr = [];
if (settings.hierarchyNotes[0] !== "") {
for (const note of settings.hierarchyNotes) {
const file = app.metadataCache.getFirstLinkpathDest(note, "");
if (file) {
hierarchyNotesArr.push(...(await this.getHierarchyNoteItems(file)));
this.addHNsToGraph(await this.getHierarchyNoteItems(file), mainG);
}
else {
new require$$0.Notice(`${note} is no longer in your vault. It is best to remove it in Breadcrumbs settings.`);
}
}
}
if (hierarchyNotesArr.length)
this.addHNsToGraph(hierarchyNotesArr, mainG);
db.end2G({ hierarchyNotesArr });
db.end2G();
// !SECTION Hierarchy Notes
console.time("Folder-Notes");
this.addFolderNotesToGraph(eligableAlts[BC_FOLDER_NOTE], frontms, mainG);
Expand Down
34 changes: 15 additions & 19 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ import MatrixView from "./MatrixView";
import {
createOrUpdateYaml,
dropWikilinks,
fallbackOppField,
getBaseFromMDPath,
getDVBasename,
getFields,
Expand Down Expand Up @@ -794,37 +795,35 @@ export default class BCPlugin extends Plugin {
return filteredLinks;
}

addHNsToGraph(hierarchyNotesArr: HierarchyNoteItem[], mainG: MultiGraph) {
addHNsToGraph(hnArr: HierarchyNoteItem[], mainG: MultiGraph) {
const { HNUpField, userHiers } = this.settings;
const upFields = getFields(userHiers, "up");

hierarchyNotesArr.forEach((hnItem, i) => {
hnArr.forEach((hnItem, i) => {
const { note, field, parent } = hnItem;
const upField = field ?? (HNUpField || upFields[0]);
const downField =
getOppFields(userHiers, upField)[0] ?? `${upField}<down>`;
getOppFields(userHiers, upField)[0] ?? fallbackOppField(upField, "up");

if (parent === null) {
const s = note;
const t = hierarchyNotesArr[i + 1]?.note;
const t = hnArr[i + 1]?.note;

addNodesIfNot(mainG, [s, t]);
addEdgeIfNot(mainG, s, t, { dir: "down", field: downField });
} else {
const aUp = {
addNodesIfNot(mainG, [note, parent]);
addEdgeIfNot(mainG, note, parent, {
dir: "up",
field: upField,
};

addNodesIfNot(mainG, [note, parent]);
addEdgeIfNot(mainG, note, parent, aUp);
});

const aDown = {
// I don't think this needs to be done if the reverse is done above
addNodesIfNot(mainG, [parent, note]);
addEdgeIfNot(mainG, parent, note, {
dir: "down",
field: downField,
};
addNodesIfNot(mainG, [parent, note]);
addEdgeIfNot(mainG, parent, note, aDown);
});
}
});
}
Expand Down Expand Up @@ -1219,15 +1218,15 @@ export default class BCPlugin extends Plugin {
this.addJugglLinksToGraph(jugglLinks, frontms, mainG);

// !SECTION Juggl Links

// SECTION Hierarchy Notes
db.start2G("Hierarchy Notes");

const hierarchyNotesArr: HierarchyNoteItem[] = [];
if (settings.hierarchyNotes[0] !== "") {
for (const note of settings.hierarchyNotes) {
const file = app.metadataCache.getFirstLinkpathDest(note, "");
if (file) {
hierarchyNotesArr.push(...(await this.getHierarchyNoteItems(file)));
this.addHNsToGraph(await this.getHierarchyNoteItems(file), mainG);
} else {
new Notice(
`${note} is no longer in your vault. It is best to remove it in Breadcrumbs settings.`
Expand All @@ -1236,10 +1235,7 @@ export default class BCPlugin extends Plugin {
}
}

if (hierarchyNotesArr.length)
this.addHNsToGraph(hierarchyNotesArr, mainG);

db.end2G({ hierarchyNotesArr });
db.end2G();
// !SECTION Hierarchy Notes

console.time("Folder-Notes");
Expand Down

0 comments on commit b3bba6d

Please sign in to comment.