Skip to content

Commit

Permalink
fix(TraverseNote): 🐛 Check if copy.hasEdge(cycle) before trying to dr…
Browse files Browse the repository at this point in the history
…opEdge
  • Loading branch information
SkepticMystic committed Jan 7, 2022
1 parent 8e9eac0 commit 49ca521
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 4 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22421,7 +22421,7 @@ function removeCycles(g, startNode) {
let prevNode = null;
graphologyTraversal.dfsFromNode(copy, startNode, (n) => {
copy.forEachOutNeighbor(n, (t) => {
if (t === prevNode) {
if (t === prevNode && copy.hasEdge(t, prevNode)) {
copy.dropEdge(t, prevNode);
}
});
Expand Down Expand Up @@ -51827,6 +51827,9 @@ class BCPlugin extends require$$0.Plugin {
};
this.getAllTags = (file, withHash = true) => {
var _a, _b, _c;
// const test = getAllTags(
// this.app.metadataCache.getFileCache(this.app.workspace.getActiveFile())
// );
const { tags, frontmatter } = this.app.metadataCache.getFileCache(file);
return [
...((_a = tags === null || tags === void 0 ? void 0 : tags.map((t) => (t.tag.startsWith("#") ? t.tag.slice(1) : t.tag))) !== null && _a !== void 0 ? _a : []),
Expand Down
2 changes: 1 addition & 1 deletion src/graphUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export function removeCycles(g: Graph, startNode: string) {
let prevNode = null;
dfsFromNode(copy, startNode, (n) => {
copy.forEachOutNeighbor(n, (t) => {
if (t === prevNode) {
if (t === prevNode && copy.hasEdge(t, prevNode)) {
copy.dropEdge(t, prevNode);
}
});
Expand Down
6 changes: 4 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getApi } from "@aidenlx/folder-note-core";
import Graph, { MultiGraph } from "graphology";
import { parseTypedLink } from "juggl-api";
import { cloneDeep, split } from "lodash";
import { cloneDeep } from "lodash";
import { debug, error, info, warn } from "loglevel";
import {
addIcon,
Expand Down Expand Up @@ -46,7 +46,6 @@ import {
DUCK_ICON_SVG,
DUCK_VIEW,
MATRIX_VIEW,
regNFlags,
splitLinksRegex,
STATS_VIEW,
TRAIL_ICON,
Expand Down Expand Up @@ -1079,6 +1078,9 @@ export default class BCPlugin extends Plugin {
}

getAllTags = (file: TFile, withHash = true): string[] => {
// const test = getAllTags(
// this.app.metadataCache.getFileCache(this.app.workspace.getActiveFile())
// );
const { tags, frontmatter } = this.app.metadataCache.getFileCache(file);
return [
...(tags?.map((t) => (t.tag.startsWith("#") ? t.tag.slice(1) : t.tag)) ??
Expand Down

0 comments on commit 49ca521

Please sign in to comment.