Skip to content

Commit

Permalink
fix(impliedRelations): 🐛 GetOppFallback if needed inside reflexiveClo…
Browse files Browse the repository at this point in the history
…sure
  • Loading branch information
SkepticMystic committed Jan 21, 2022
1 parent a584da5 commit 0ee790f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 6 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4800,11 +4800,12 @@ function getSubForFields(main, fields) {
function getReflexiveClosure(g, userHiers, closeAsOpposite = true) {
const copy = g.copy();
copy.forEachEdge((k, a, s, t) => {
var _a;
const { dir, field } = a;
if (field === undefined)
return;
const oppDir = getOppDir(dir);
const oppField = getOppFields(userHiers, field)[0];
const oppField = (_a = getOppFields(userHiers, field)[0]) !== null && _a !== void 0 ? _a : fallbackOppField(field, dir);
addNodesIfNot(copy, [s, t], {
//@ts-ignore
dir: closeAsOpposite ? oppDir : dir,
Expand Down Expand Up @@ -4866,6 +4867,9 @@ function getFieldInfo(userHiers, field) {
return { fieldHier, fieldDir };
}
function getOppFields(userHiers, field) {
// 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);
const oppDir = getOppDir(fieldDir);
return fieldHier[oppDir];
Expand Down Expand Up @@ -27957,7 +27961,7 @@ function create_each_block$5(ctx) {
}

t = space();
attr(div, "class", "svelte-sp0k97");
attr(div, "class", "BC-matrix-hier svelte-sp0k97");
},
m(target, anchor) {
insert(target, div, anchor);
Expand Down
9 changes: 7 additions & 2 deletions src/graphUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ import type {
NodePath,
UserHier,
} from "./interfaces";
import { getBaseFromMDPath, getFields } from "./sharedFunctions";
import {
fallbackOppField,
getBaseFromMDPath,
getFields,
} from "./sharedFunctions";

// TODO - this is a hack to get the graph to work with the approvals
// I shouldn't need
Expand Down Expand Up @@ -90,7 +94,8 @@ export function getReflexiveClosure(
const { dir, field } = a;
if (field === undefined) return;
const oppDir = getOppDir(dir);
const oppField = getOppFields(userHiers, field)[0];
const oppField =
getOppFields(userHiers, field)[0] ?? fallbackOppField(field, dir);

addNodesIfNot(copy, [s, t], {
//@ts-ignore
Expand Down

0 comments on commit 0ee790f

Please sign in to comment.