Skip to content

Commit

Permalink
fix: indexNote arr
Browse files Browse the repository at this point in the history
  • Loading branch information
SkepticMystic committed Jul 1, 2021
1 parent e091685 commit 9800573
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 22 deletions.
6 changes: 3 additions & 3 deletions src/BreadcrumbsSettingTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class BreadcrumbsSettingTab extends PluginSettingTab {
plugin.currGraphs = await plugin.initGraphs();
}
if (plugin.trailDiv) {
await plugin.drawTrail(plugin.currGraphs.gParents);
await plugin.drawTrail();
}
if (plugin.matrixView) {
await plugin.matrixView.draw();
Expand Down Expand Up @@ -166,7 +166,7 @@ export class BreadcrumbsSettingTab extends PluginSettingTab {
: ""
}`,
});
await plugin.drawTrail(plugin.currGraphs.gParents);
await plugin.drawTrail();
} else {
plugin.trailDiv.remove();
}
Expand All @@ -182,7 +182,7 @@ export class BreadcrumbsSettingTab extends PluginSettingTab {
let finalValue: string[];
text
.setPlaceholder("Index Note")
.setValue(plugin.settings.indexNote.join(", "))
.setValue([plugin.settings.indexNote].flat().join(", "))
.onChange(async (value) => {
finalValue = splitAndTrim(value);
});
Expand Down
70 changes: 52 additions & 18 deletions src/MatrixView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,6 @@ export default class MatrixView extends ItemView {

// ANCHOR Remove duplicate implied links

// removeDuplicateImpliedBetter(
// real: internalLinkObj[],
// implied: internalLinkObj[]
// ): internalLinkObj[] {
// implied = implied.filter((impliedItem, i, self) => {
// real.forEach((realItem) => {
// return !(i === self.findIndex((t) => t.to));
// });
// });
// return implied;
// }

removeDuplicateImplied(
real: internalLinkObj[],
implied: internalLinkObj[]
Expand All @@ -116,21 +104,67 @@ export default class MatrixView extends ItemView {
});
}

nextLevel(obj: { [x: string]: any }, gChildren: Graph): void {
for (const child in obj) {
if (Object.prototype.hasOwnProperty.call(obj, child)) {
const childrenOfChild = (gChildren.successors(obj[child]) ??
[]) as string[];
childrenOfChild.forEach((innerChild) => (obj[child] = { innerChild }));
obj[child] = { ...childrenOfChild };
}
}
}

// createIndexObj(gChildren: Graph, currFile: string, depth: number) {
// const initialChildren: [string, number][][] = [[]];

// const immediateChildren = (gChildren.successors(currFile) ??
// []) as string[];
// immediateChildren.forEach((child) => initialChildren[0].push([child, 1]));

// console.log(initialChildren);

// for (let i = 0; i < depth; i++) {
// initialChildren.push([]);
// initialChildren[i].forEach((childArr) => {
// const childrenOfChild = (
// (gChildren.successors(childArr[0]) ?? []) as string[]
// ).map((child) => [child, i + 2]);
// initialChildren[i + 1].push(childrenOfChild);
// });
// }
// console.log(initialChildren);
// }

async draw(): Promise<void> {
this.contentEl.empty();
this.currGraphs = this.plugin.currGraphs;
const currFile = this.app.workspace.getActiveFile();
const settings = this.plugin.settings;

const button = this.contentEl.createEl("button", {
const viewToggleButton = this.contentEl.createEl("button", {
text: this.matrixQ ? "List" : "Matrix",
});
button.addEventListener("click", async () => {
viewToggleButton.addEventListener("click", async () => {
this.matrixQ = !this.matrixQ;
button.innerText = this.matrixQ ? "List" : "Matrix";
viewToggleButton.innerText = this.matrixQ ? "List" : "Matrix";
await this.draw();
});

// const createIndexButton = this.contentEl.createEl("button", {
// text: "Create Index",
// });
// createIndexButton.addEventListener("click", () =>
// console.log(
// this.createIndexObj(
// this.plugin.currGraphs.gChildren,
// currFile.basename,
// 2
// )
// )
// );

this.currGraphs = this.plugin.currGraphs;
const currFile = this.app.workspace.getActiveFile();
const settings = this.plugin.settings;

const [parentFieldName, siblingFieldName, childFieldName] = [
settings.showNameOrType ? settings.parentFieldName : "Parent",
settings.showNameOrType ? settings.siblingFieldName : "Sibling",
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export default class BreadcrumbsPlugin extends Plugin {
getShortestBreadcrumbs(g: Graph): string[] {
const from = this.app.workspace.getActiveFile().basename;
const paths = graphlib.alg.dijkstra(g, from);
const indexNotes: string[] = this.settings.indexNote;
const indexNotes: string[] = [this.settings.indexNote].flat();

const allTrails: string[][] = [];

Expand Down

0 comments on commit 9800573

Please sign in to comment.