Skip to content

Commit

Permalink
fix(List/Matrix View): 🐛 Fallback field name
Browse files Browse the repository at this point in the history
  • Loading branch information
SkepticMystic committed Nov 22, 2021
1 parent 5403d87 commit 523585c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 12 deletions.
29 changes: 22 additions & 7 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -21947,6 +21947,8 @@ function getReflexiveClosure(g, userHiers, closeAsOpposite = true) {
const copy = g.copy();
copy.forEachEdge((k, a, s, t) => {
const { dir, field } = a;
if (field === undefined)
return;
const oppDir = getOppDir(dir);
const oppField = getOppFields(userHiers, field)[0];
addNodesIfNot(copy, [s, t], {
Expand Down Expand Up @@ -23442,7 +23444,9 @@ class MatrixView extends obsidian.ItemView {
return [];
}
const { basename } = currFile;
const up = getSubInDirs(mainG, "up");
const g = getSubInDirs(mainG, "up", "down");
const closed = getReflexiveClosure(g, userHiers);
const up = getSubInDirs(closed, "up");
const realsnImplieds = getRealnImplied(plugin, basename);
return userHiers.map((hier) => {
const filteredRealNImplied = blankRealNImplied();
Expand All @@ -23459,7 +23463,9 @@ class MatrixView extends obsidian.ItemView {
// SECTION Implied Siblings
/// Notes with the same parents
let iSameArr = [];
const currParents = getOutNeighbours(up, basename);
const currParents = up.hasNode(basename)
? up.filterOutNeighbors(basename, (n, a) => Object.values(hier).flat().includes(a.field))
: [];
currParents.forEach((parent) => {
let impliedSiblings = getInNeighbours(up, parent);
// The current note is always it's own implied sibling, so remove it from the list
Expand Down Expand Up @@ -23497,9 +23503,9 @@ class MatrixView extends obsidian.ItemView {
}
});
iSameArr = iSameNoDup;
const getFieldInHier = (dir) => hier[dir][0] === ""
? `${hier[getOppDir(dir)].join(",")}<${dir}>`
: hier[dir].join(", ");
const getFieldInHier = (dir) => hier[dir][0]
? hier[dir].join(", ")
: `${hier[getOppDir(dir)].join(",")}${ARROW_DIRECTIONS[dir]}`;
const { alphaSortAsc } = settings;
[ru, rs, rd, rn, rp, iu, iSameArr, id, iN, ip].forEach((a) => a
.sort((a, b) => a.to < b.to ? (alphaSortAsc ? -1 : 1) : alphaSortAsc ? 1 : -1)
Expand Down Expand Up @@ -25605,7 +25611,14 @@ function instance$4($$self, $$props, $$invalidate) {
};

const change_handler = async (i, dir, e) => {
$$invalidate(0, currHiers[i][dir] = splitAndTrim(e.target.value), currHiers);
const { value } = e.target;

if (value === "") {
$$invalidate(0, currHiers[i][dir] = [], currHiers);
} else {
$$invalidate(0, currHiers[i][dir] = splitAndTrim(value), currHiers);
}

await update(currHiers);
};

Expand Down Expand Up @@ -36821,7 +36834,9 @@ class BCPlugin extends obsidian.Plugin {
}
else {
const positiveFields = Object.keys(limitTrailCheckboxStates).filter((field) => limitTrailCheckboxStates[field]);
const oppFields = positiveFields.map((field) => getOppFields(userHiers, field)[0]);
const oppFields = positiveFields
.map((field) => getOppFields(userHiers, field)[0])
.filter((field) => field !== undefined);
subGraph = getSubForFields(this.mainG, [...positiveFields, ...oppFields]);
}
const closed = getReflexiveClosure(subGraph, userHiers);
Expand Down
15 changes: 10 additions & 5 deletions src/MatrixView.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { ItemView, Notice, TFile, WorkspaceLeaf } from "obsidian";
import { blankRealNImplied, MATRIX_VIEW, TRAIL_ICON } from "src/constants";
import {
ARROW_DIRECTIONS,
blankRealNImplied,
MATRIX_VIEW,
TRAIL_ICON,
} from "src/constants";
import type {
BCSettings,
Directions,
Expand All @@ -12,8 +17,8 @@ import {
debugGroupStart,
getInNeighbours,
getOppDir,
getOutNeighbours,
getRealnImplied,
getReflexiveClosure,
getSubInDirs,
linkClass,
} from "src/sharedFunctions";
Expand Down Expand Up @@ -201,9 +206,9 @@ export default class MatrixView extends ItemView {
iSameArr = iSameNoDup;

const getFieldInHier = (dir: Directions) =>
hier[dir][0] === ""
? `${hier[getOppDir(dir)].join(",")}<${dir}>`
: hier[dir].join(", ");
hier[dir][0]
? hier[dir].join(", ")
: `${hier[getOppDir(dir)].join(",")}${ARROW_DIRECTIONS[dir]}`;

const { alphaSortAsc } = settings;
[ru, rs, rd, rn, rp, iu, iSameArr, id, iN, ip].forEach((a) =>
Expand Down

0 comments on commit 523585c

Please sign in to comment.