Skip to content

Commit

Permalink
fix(DendronNote): 🐛 Don't return if g.hasNode. It may already have it…
Browse files Browse the repository at this point in the history
… from other means
  • Loading branch information
SkepticMystic committed Dec 14, 2021
1 parent 7acffcf commit f7c4fe4
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 9 deletions.
40 changes: 35 additions & 5 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -52061,14 +52061,13 @@ class BCPlugin extends require$$0.Plugin {
const { addDendronNotes, dendronNoteDelimiter, dendronNoteField } = this.settings;
if (!addDendronNotes)
return;
frontms.forEach((frontm) => {
for (const frontm of frontms) {
const { file } = frontm;
const basename = getDVBasename(file);
if (mainG.hasNode(basename))
return;
const splits = basename.split(dendronNoteDelimiter);
if (splits.length < 2)
return;
continue;
// Probably inefficient to reverse then unreverse it. I can probably just use slice(-i)
const reversed = splits.reverse();
reversed.forEach((split, i) => {
const currSlice = reversed
Expand All @@ -52085,7 +52084,38 @@ class BCPlugin extends require$$0.Plugin {
const targetOrder = this.getTargetOrder(frontms, nextSlice);
this.populateMain(mainG, currSlice, dendronNoteField, nextSlice, sourceOrder, targetOrder, true);
});
});
}
// frontms.forEach((frontm) => {
// const { file } = frontm;
// const basename = getDVBasename(file);
// // It could have the node from another means already, but that doesn't mean it should return...
// // if (mainG.hasNode(basename)) return;
// const splits = basename.split(dendronNoteDelimiter);
// if (splits.length < 2) return;
// const reversed = splits.reverse();
// reversed.forEach((split, i) => {
// const currSlice = reversed
// .slice(i)
// .reverse()
// .join(dendronNoteDelimiter);
// const nextSlice = reversed
// .slice(i + 1)
// .reverse()
// .join(dendronNoteDelimiter);
// if (!nextSlice) return;
// const sourceOrder = this.getSourceOrder(frontm);
// const targetOrder = this.getTargetOrder(frontms, nextSlice);
// this.populateMain(
// mainG,
// currSlice,
// dendronNoteField,
// nextSlice,
// sourceOrder,
// targetOrder,
// true
// );
// });
// });
}
async initGraphs() {
const mainG = new graphology_umd_min.MultiGraph();
Expand Down
43 changes: 39 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1033,14 +1033,14 @@ export default class BCPlugin extends Plugin {
this.settings;
if (!addDendronNotes) return;

frontms.forEach((frontm) => {
for (const frontm of frontms) {
const { file } = frontm;
const basename = getDVBasename(file);
if (mainG.hasNode(basename)) return;

const splits = basename.split(dendronNoteDelimiter);
if (splits.length < 2) return;
if (splits.length < 2) continue;

// Probably inefficient to reverse then unreverse it. I can probably just use slice(-i)
const reversed = splits.reverse();
reversed.forEach((split, i) => {
const currSlice = reversed
Expand All @@ -1066,7 +1066,42 @@ export default class BCPlugin extends Plugin {
true
);
});
});
}
// frontms.forEach((frontm) => {
// const { file } = frontm;
// const basename = getDVBasename(file);
// // It could have the node from another means already, but that doesn't mean it should return...
// // if (mainG.hasNode(basename)) return;

// const splits = basename.split(dendronNoteDelimiter);
// if (splits.length < 2) return;

// const reversed = splits.reverse();
// reversed.forEach((split, i) => {
// const currSlice = reversed
// .slice(i)
// .reverse()
// .join(dendronNoteDelimiter);
// const nextSlice = reversed
// .slice(i + 1)
// .reverse()
// .join(dendronNoteDelimiter);
// if (!nextSlice) return;

// const sourceOrder = this.getSourceOrder(frontm);
// const targetOrder = this.getTargetOrder(frontms, nextSlice);

// this.populateMain(
// mainG,
// currSlice,
// dendronNoteField,
// nextSlice,
// sourceOrder,
// targetOrder,
// true
// );
// });
// });
}

getTargetOrder = (frontms: dvFrontmatterCache[], target: string) =>
Expand Down

0 comments on commit f7c4fe4

Please sign in to comment.