Skip to content

Commit

Permalink
fix(Codeblock): 🐛 Safety on field in codeblockError
Browse files Browse the repository at this point in the history
  • Loading branch information
SkepticMystic committed Jan 10, 2022
1 parent bb25b48 commit 6a3d42f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
19 changes: 16 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -21160,6 +21160,7 @@ const DEFAULT_SETTINGS = {
showTrail: true,
showGrid: true,
showPrevNext: true,
sortByNameShowAlias: false,
squareDirectionsOrder: [0, 1, 2, 3, 4],
limitTrailCheckboxes: [],
limitJumpToFirstFields: [],
Expand Down Expand Up @@ -24944,7 +24945,7 @@ class MatrixView extends require$$0.ItemView {
getHierSquares(userHiers, currFile) {
const { plugin } = this;
const { mainG, settings } = plugin;
const { alphaSortAsc, enableAlphaSort, treatCurrNodeAsImpliedSibling, squareDirectionsOrder, } = settings;
const { alphaSortAsc, enableAlphaSort, treatCurrNodeAsImpliedSibling, squareDirectionsOrder, sortByNameShowAlias, } = settings;
if (!mainG)
return [];
const { basename } = currFile;
Expand Down Expand Up @@ -25007,7 +25008,8 @@ class MatrixView extends require$$0.ItemView {
if (enableAlphaSort) {
squares.forEach((sq) => sq.sort((a, b) => {
var _a, _b;
return ((_a = a.alt) !== null && _a !== void 0 ? _a : a.to) < ((_b = b.alt) !== null && _b !== void 0 ? _b : b.to)
return (sortByNameShowAlias ? a.to : (_a = a.alt) !== null && _a !== void 0 ? _a : a.to) <
(sortByNameShowAlias ? b.to : (_b = b.alt) !== null && _b !== void 0 ? _b : b.to)
? alphaSortAsc
? -1
: 1
Expand Down Expand Up @@ -25356,6 +25358,16 @@ class BCSettingTab extends require$$0.PluginSettingTab {
await plugin.saveSettings();
await plugin.getActiveTYPEView(MATRIX_VIEW).draw();
}));
new require$$0.Setting(MLViewDetails)
.setName("Sort by note name, but show alias")
.setDesc("When this is turned off, notes will first be sorted by their alias, and then by their name if no alias is found. Turn this on to sort by note name always, but still show the alias in the results.")
.addToggle((toggle) => toggle
.setValue(settings.sortByNameShowAlias)
.onChange(async (value) => {
settings.sortByNameShowAlias = value;
await plugin.saveSettings();
await plugin.getActiveTYPEView(MATRIX_VIEW).draw();
}));
new require$$0.Setting(MLViewDetails)
.setName("Make Current Note an Implied Sibling")
.setDesc("Techincally, the current note is always it's own implied sibling. By default, it is not show as such. Toggle this on to make it show.")
Expand Down Expand Up @@ -53087,6 +53099,7 @@ class BCPlugin extends require$$0.Plugin {
return results;
}
codeblockError(parsedSource) {
var _a;
const { dir, fields, type, title, depth, flat, content } = parsedSource;
const { userHiers } = this.settings;
let err = "";
Expand All @@ -53096,7 +53109,7 @@ class BCPlugin extends require$$0.Plugin {
if (!validDir)
err += `<code>dir: ${dir}</code> is not a valid direction.</br>`;
const allFields = getFields(userHiers);
fields === null || fields === void 0 ? void 0 : fields.forEach((f) => {
(_a = [fields].flat()) === null || _a === void 0 ? void 0 : _a.forEach((f) => {
if (!allFields.includes(f))
err += `<code>field: ${f}</code> is not a field in your hierarchies.</br>`;
});
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ export default class BCPlugin extends Plugin {
err += `<code>dir: ${dir}</code> is not a valid direction.</br>`;

const allFields = getFields(userHiers);
fields?.forEach((f) => {
[fields].flat()?.forEach((f) => {
if (!allFields.includes(f))
err += `<code>field: ${f}</code> is not a field in your hierarchies.</br>`;
});
Expand Down

0 comments on commit 6a3d42f

Please sign in to comment.