Skip to content

Commit

Permalink
fix(List/Matrix View): 🐛 BC-order was being overwritten
Browse files Browse the repository at this point in the history
  • Loading branch information
SkepticMystic committed Dec 4, 2021
1 parent 0847249 commit c673420
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 44 deletions.
62 changes: 29 additions & 33 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -20849,11 +20849,13 @@ function getReflexiveClosure(g, userHiers, closeAsOpposite = true) {
});
return copy;
}
function addNodesIfNot(g, nodes, attr) {
nodes.forEach((node) => {
if (!g.hasNode(node))
g.addNode(node, attr);
});
function addNodesIfNot(g, nodes, attr = { order: 9999 }) {
for (const node of nodes) {
g.updateNode(node, (exstantAttrs) => {
const extantOrder = exstantAttrs.order;
return Object.assign(Object.assign({}, exstantAttrs), { order: extantOrder && extantOrder < 9999 ? extantOrder : attr.order });
});
}
}
function addEdgeIfNot(g, source, target, attr) {
if (!g.hasEdge(source, target))
Expand Down Expand Up @@ -24845,7 +24847,6 @@ class MatrixView extends require$$0.ItemView {
iSamesII.push(this.toInternalLinkObj(s, false, parent));
});
});
/// A real sibling implies the reverse sibling
is.push(...iSamesII);
// !SECTION
iu = this.removeDuplicateImplied(ru, iu);
Expand Down Expand Up @@ -49850,29 +49851,29 @@ class BCPlugin extends require$$0.Plugin {
for (const item of listItems) {
const currItem = lines[item.position.start.line];
const afterBulletCurr = afterBulletReg.exec(currItem)[1];
const dropWikiCurr = dropWikiLinksReg.exec(afterBulletCurr)[1];
let fieldCurr = fieldReg.exec(afterBulletCurr)[1].trim() || null;
const note = dropWikiLinksReg.exec(afterBulletCurr)[1];
let field = fieldReg.exec(afterBulletCurr)[1].trim() || null;
// Ensure fieldName is one of the existing up fields. `null` if not
if (fieldCurr !== null && !upFields.includes(fieldCurr)) {
problemFields.push(fieldCurr);
fieldCurr = null;
if (field !== null && !upFields.includes(field)) {
problemFields.push(field);
field = null;
}
const { parent } = item;
if (parent >= 0) {
const parentNote = lines[parent];
const afterBulletParent = afterBulletReg.exec(parentNote)[1];
const dropWikiParent = dropWikiLinksReg.exec(afterBulletParent)[1];
hierarchyNoteItems.push({
currNote: dropWikiCurr,
parentNote: dropWikiParent,
field: fieldCurr,
note,
parent: dropWikiParent,
field,
});
}
else {
hierarchyNoteItems.push({
currNote: dropWikiCurr,
parentNote: null,
field: fieldCurr,
note,
parent: null,
field,
});
}
}
Expand Down Expand Up @@ -50125,34 +50126,29 @@ class BCPlugin extends require$$0.Plugin {
const { HNUpField, userHiers } = this.settings;
const upFields = getFields(userHiers, "up");
hierarchyNotesArr.forEach((hnItem, i) => {
var _a, _b, _c;
const upField = (_a = hnItem.field) !== null && _a !== void 0 ? _a : (HNUpField || upFields[0]);
const downField = (_b = getOppFields(userHiers, upField)[0]) !== null && _b !== void 0 ? _b : `${upField}<down>`;
if (hnItem.parentNote === null) {
const s = hnItem.currNote;
const t = (_c = hierarchyNotesArr[i + 1]) === null || _c === void 0 ? void 0 : _c.currNote;
//@ts-ignore
var _a, _b;
const { note, field, parent } = hnItem;
const upField = field !== null && field !== void 0 ? field : (HNUpField || upFields[0]);
const downField = (_a = getOppFields(userHiers, upField)[0]) !== null && _a !== void 0 ? _a : `${upField}<down>`;
if (parent === null) {
const s = note;
const t = (_b = hierarchyNotesArr[i + 1]) === null || _b === void 0 ? void 0 : _b.note;
addNodesIfNot(mainG, [s, t]);
//@ts-ignore
addEdgeIfNot(mainG, s, t, { dir: "down", field: downField });
}
else {
const aUp = {
dir: "up",
field: upField,
};
//@ts-ignore
addNodesIfNot(mainG, [hnItem.currNote, hnItem.parentNote]);
//@ts-ignore
addEdgeIfNot(mainG, hnItem.currNote, hnItem.parentNote, aUp);
addNodesIfNot(mainG, [note, parent]);
addEdgeIfNot(mainG, note, parent, aUp);
const aDown = {
dir: "down",
field: downField,
};
//@ts-ignore
addNodesIfNot(mainG, [hnItem.parentNote, hnItem.currNote]);
//@ts-ignore
addEdgeIfNot(mainG, hnItem.parentNote, hnItem.currNote, aDown);
addNodesIfNot(mainG, [parent, note]);
addEdgeIfNot(mainG, parent, note, aDown);
}
});
}
Expand Down
10 changes: 3 additions & 7 deletions src/MatrixView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,11 @@ export default class MatrixView extends ItemView {
const { reals, implieds } = realsnImplieds[dir];
filteredRealNImplied[dir].reals = reals
.filter((real) => hier[dir].includes(real.field))
.map((item) =>
this.toInternalLinkObj(item.to, true)
) as internalLinkObj[];
.map((item) => this.toInternalLinkObj(item.to, true));

filteredRealNImplied[dir].implieds = implieds
.filter((implied) => hier[dir].includes(implied.field))
.map((item) =>
this.toInternalLinkObj(item.to, false)
) as internalLinkObj[];
.map((item) => this.toInternalLinkObj(item.to, false));
}

let {
Expand Down Expand Up @@ -168,7 +165,6 @@ export default class MatrixView extends ItemView {
});
});

/// A real sibling implies the reverse sibling
is.push(...iSamesII);

// !SECTION
Expand Down
14 changes: 10 additions & 4 deletions src/graphUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,17 @@ export function getReflexiveClosure(
export function addNodesIfNot(
g: MultiGraph,
nodes: string[],
attr?: { order: number }
attr = { order: 9999 }
) {
nodes.forEach((node) => {
if (!g.hasNode(node)) g.addNode(node, attr);
});
for (const node of nodes) {
g.updateNode(node, (exstantAttrs) => {
const extantOrder: number | undefined = exstantAttrs.order;
return {
...exstantAttrs,
order: extantOrder && extantOrder < 9999 ? extantOrder : attr.order,
};
});
}
}

export function addEdgeIfNot(
Expand Down
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,7 @@ export default class BCPlugin extends Plugin {

values.forEach((target) => {
const targetOrder = this.getTargetOrder(frontms, target);

this.populateMain(
mainG,
basename,
Expand Down

0 comments on commit c673420

Please sign in to comment.