Skip to content

Commit

Permalink
fix: 🐛 Fail silently if hier.next/prev is undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
SkepticMystic committed Nov 18, 2021
1 parent 546d3e7 commit d76d5b2
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 32 deletions.
27 changes: 19 additions & 8 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -19952,7 +19952,8 @@ async function getJugglLinks(app, settings) {
let typeDir = "";
DIRECTIONS.forEach((dir) => {
userHierarchies.forEach((hier) => {
if (hier[dir].includes(type)) {
var _a;
if ((_a = hier[dir]) === null || _a === void 0 ? void 0 : _a.includes(type)) {
typeDir = dir;
return;
}
Expand Down Expand Up @@ -23573,22 +23574,31 @@ class BCSettingTab extends obsidian.PluginSettingTab {
new obsidian.Setting(trailDetails)
.setName("Views to show")
.setDesc("Choose which of the views to show at the top of the note.\nTrail, Grid, and/or the Next-Previous view.")
.addToggle(toggle => {
toggle.setTooltip('Show Trail view').setValue(settings.showTrail).onChange(async (value) => {
.addToggle((toggle) => {
toggle
.setTooltip("Show Trail view")
.setValue(settings.showTrail)
.onChange(async (value) => {
settings.showTrail = value;
await plugin.saveSettings();
await plugin.drawTrail();
});
})
.addToggle(toggle => {
toggle.setTooltip('Show Grid view').setValue(settings.showGrid).onChange(async (value) => {
.addToggle((toggle) => {
toggle
.setTooltip("Show Grid view")
.setValue(settings.showGrid)
.onChange(async (value) => {
settings.showGrid = value;
await plugin.saveSettings();
await plugin.drawTrail();
});
})
.addToggle(toggle => {
toggle.setTooltip('Show Next/Previous view').setValue(settings.showPrevNext).onChange(async (value) => {
.addToggle((toggle) => {
toggle
.setTooltip("Show Next/Previous view")
.setValue(settings.showPrevNext)
.onChange(async (value) => {
settings.showPrevNext = value;
await plugin.saveSettings();
await plugin.drawTrail();
Expand Down Expand Up @@ -23718,7 +23728,8 @@ class BCSettingTab extends obsidian.PluginSettingTab {
const checkboxStates = settings.limitWriteBCCheckboxStates;
settings.userHierarchies.forEach((userHier) => {
DIRECTIONS.forEach((dir) => {
userHier[dir].forEach(async (field) => {
var _a;
(_a = userHier[dir]) === null || _a === void 0 ? void 0 : _a.forEach(async (field) => {
if (field === "")
return;
// First sort out limitWriteBCCheckboxStates
Expand Down
53 changes: 30 additions & 23 deletions src/BreadcrumbsSettingTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,7 @@ export class BCSettingTab extends PluginSettingTab {

new Setting(trailDetails)
.setName("Show Breadcrumbs")
.setDesc(
"Show a set of different views at the top of the current note."
)
.setDesc("Show a set of different views at the top of the current note.")
.addToggle((toggle) =>
toggle.setValue(settings.showBCs).onChange(async (value) => {
settings.showBCs = value;
Expand Down Expand Up @@ -430,27 +428,36 @@ export class BCSettingTab extends PluginSettingTab {
.setDesc(
"Choose which of the views to show at the top of the note.\nTrail, Grid, and/or the Next-Previous view."
)
.addToggle(toggle => {
toggle.setTooltip('Show Trail view').setValue(settings.showTrail).onChange(async (value) => {
settings.showTrail = value;
await plugin.saveSettings();
await plugin.drawTrail();
})
})
.addToggle(toggle => {
toggle.setTooltip('Show Grid view').setValue(settings.showGrid).onChange(async (value) => {
settings.showGrid = value;
await plugin.saveSettings();
await plugin.drawTrail();
})
.addToggle((toggle) => {
toggle
.setTooltip("Show Trail view")
.setValue(settings.showTrail)
.onChange(async (value) => {
settings.showTrail = value;
await plugin.saveSettings();
await plugin.drawTrail();
});
})
.addToggle(toggle => {
toggle.setTooltip('Show Next/Previous view').setValue(settings.showPrevNext).onChange(async (value) => {
settings.showPrevNext = value;
await plugin.saveSettings();
await plugin.drawTrail();
})
.addToggle((toggle) => {
toggle
.setTooltip("Show Grid view")
.setValue(settings.showGrid)
.onChange(async (value) => {
settings.showGrid = value;
await plugin.saveSettings();
await plugin.drawTrail();
});
})
.addToggle((toggle) => {
toggle
.setTooltip("Show Next/Previous view")
.setValue(settings.showPrevNext)
.onChange(async (value) => {
settings.showPrevNext = value;
await plugin.saveSettings();
await plugin.drawTrail();
});
});

new Setting(trailDetails)
.setName("Grid view dots")
Expand Down Expand Up @@ -619,7 +626,7 @@ export class BCSettingTab extends PluginSettingTab {

settings.userHierarchies.forEach((userHier) => {
DIRECTIONS.forEach((dir) => {
userHier[dir].forEach(async (field) => {
userHier[dir]?.forEach(async (field) => {
if (field === "") return;
// First sort out limitWriteBCCheckboxStates
if (checkboxStates[field] === undefined) {
Expand Down
2 changes: 1 addition & 1 deletion src/sharedFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export async function getJugglLinks(
let typeDir: Directions | "" = "";
DIRECTIONS.forEach((dir) => {
userHierarchies.forEach((hier) => {
if (hier[dir].includes(type)) {
if (hier[dir]?.includes(type)) {
typeDir = dir;
return;
}
Expand Down

0 comments on commit d76d5b2

Please sign in to comment.