Skip to content

Commit

Permalink
fix: 🐛 return undefined if a corresponding dir opr hier can't be foun…
Browse files Browse the repository at this point in the history
…d for a field
  • Loading branch information
SkepticMystic committed Jan 21, 2022
1 parent fdc4228 commit 013e161
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
15 changes: 5 additions & 10 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4871,6 +4871,8 @@ function getOppFields(userHiers, field) {
if (field.endsWith(">"))
return field.slice(0, -4);
const { fieldHier, fieldDir } = getFieldInfo(userHiers, field);
if (!fieldHier || !fieldDir)
return undefined;
const oppDir = getOppDir(fieldDir);
return fieldHier[oppDir];
}
Expand Down Expand Up @@ -25173,16 +25175,9 @@ async function drawTrail(plugin) {
db.end2G();
return;
}
let view;
let livePreview = false;
if (mode === "preview") {
view = activeMDView.previewMode.containerEl.querySelector("div.markdown-preview-view");
}
else {
view = activeMDView.contentEl.querySelector("div.markdown-source-view");
if (view.hasClass("is-live-preview"))
livePreview = true;
}
const view = mode === "preview"
? activeMDView.previewMode.containerEl.querySelector("div.markdown-preview-view")
: activeMDView.contentEl.querySelector("div.markdown-source-view");
(_c = activeMDView.containerEl
.querySelectorAll(".BC-trail")) === null || _c === void 0 ? void 0 : _c.forEach((trail) => trail.remove());
const closedUp = getLimitedTrailSub(plugin);
Expand Down
23 changes: 13 additions & 10 deletions src/Views/TrailView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ function getLimitedTrailSub(plugin: BCPlugin) {
return getSubInDirs(closed, "up");
}

function getGraphForTrail(plugin: BCPlugin) {
const { closedG } = plugin;
const { userHiers, limitTrailCheckboxes } = plugin.settings;

closedG;
}

function getBreadcrumbs(
settings: BCSettings,
g: MultiGraph,
Expand Down Expand Up @@ -140,16 +147,12 @@ export async function drawTrail(plugin: BCPlugin): Promise<void> {
return;
}

let view: HTMLElement;
let livePreview: boolean = false;
if (mode === "preview") {
view = activeMDView.previewMode.containerEl.querySelector(
"div.markdown-preview-view"
);
} else {
view = activeMDView.contentEl.querySelector("div.markdown-source-view");
if (view.hasClass("is-live-preview")) livePreview = true;
}
const view =
mode === "preview"
? activeMDView.previewMode.containerEl.querySelector(
"div.markdown-preview-view"
)
: activeMDView.contentEl.querySelector("div.markdown-source-view");

activeMDView.containerEl
.querySelectorAll(".BC-trail")
Expand Down
1 change: 1 addition & 0 deletions src/graphUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ export function getOppFields(userHiers: UserHier[], field: string) {
// If the field ends with `>`, it is already the opposite field we need (coming from getOppFallback`)
if (field.endsWith(">")) return field.slice(0, -4);
const { fieldHier, fieldDir } = getFieldInfo(userHiers, field);
if (!fieldHier || !fieldDir) return undefined;
const oppDir = getOppDir(fieldDir);
return fieldHier[oppDir];
}
Expand Down

0 comments on commit 013e161

Please sign in to comment.