Skip to content

Commit

Permalink
feat(List/Matrix View): ✨ Hook closedG into m/l view (new relation ty…
Browse files Browse the repository at this point in the history
…pes!). The new types are added as a class to the `li`
  • Loading branch information
SkepticMystic committed Jan 16, 2022
1 parent 5e7d46a commit 4572689
Show file tree
Hide file tree
Showing 7 changed files with 2,331 additions and 2,339 deletions.
4,604 changes: 2,300 additions & 2,304 deletions main.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/Components/Lists.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

<ol>
{#each square.realItems as realItem}
<li>
<li class={realItem.implied ?? ""}>
<div
class={realItem.cls}
on:click={async (e) => openOrSwitch(app, realItem.to, e)}
Expand All @@ -66,7 +66,7 @@
class="BC-Implied {treatCurrNodeAsImpliedSibling &&
impliedItem.to === currFile.basename
? 'BC-active-note'
: ''}"
: ''} {impliedItem.implied ?? ''}"
>
<div
class={impliedItem.cls}
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Matrix.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
{#if square.realItems.length}
<ol>
{#each square.realItems as realItem}
<li>
<li class={realItem.implied ?? ""}>
<div
class={realItem.cls}
on:click={async (e) => openOrSwitch(app, realItem.to, e)}
Expand Down Expand Up @@ -70,7 +70,7 @@
class="BC-Implied {treatCurrNodeAsImpliedSibling &&
impliedItem.to === currFile.basename
? 'BC-active-note'
: ''}"
: ''} {impliedItem.implied ?? ''}"
>
<div
class={impliedItem.cls}
Expand Down
29 changes: 9 additions & 20 deletions src/Views/MatrixView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,16 @@ export default class MatrixView extends ItemView {
toInternalLinkObj = (
to: string,
realQ = true,
parent?: string
parent: string | null,
implied?: string
): internalLinkObj => {
return {
to,
cls: linkClass(this.app, to, realQ),
alt: this.getAlt(to),
order: this.getOrder(to),
parent,
implied,
};
};

Expand Down Expand Up @@ -149,11 +151,15 @@ export default class MatrixView extends ItemView {

filteredRealNImplied[dir].reals = reals
.filter((real) => resultsFilter(real, dir, oppDir, arrow))
.map((item) => this.toInternalLinkObj(item.to, true));
.map((item) =>
this.toInternalLinkObj(item.to, true, null, item.implied)
);

filteredRealNImplied[dir].implieds = implieds
.filter((implied) => resultsFilter(implied, dir, oppDir, arrow))
.map((item) => this.toInternalLinkObj(item.to, false));
.map((item) =>
this.toInternalLinkObj(item.to, false, null, item.implied)
);
}

let {
Expand All @@ -164,23 +170,6 @@ export default class MatrixView extends ItemView {
prev: { reals: rp, implieds: ip },
} = filteredRealNImplied;

// SECTION Implied Siblings
/// Notes with the same parents
const closedUp = getSubInDirs(plugin.closedG, "up");

const iSamesII: internalLinkObj[] = [];
if (closedUp.hasNode(basename)) {
closedUp.forEachOutEdge(basename, (k, a, s, par) => {
if (hier.up.includes(a.field)) {
closedUp.forEachInEdge(par, (k, a, s, t) => {
if (s === basename && !treatCurrNodeAsImpliedSibling) return;
iSamesII.push(this.toInternalLinkObj(s, false, t));
});
}
});
}
is.push(...iSamesII);

// !SECTION

[iu, is, id, iN, ip] = [
Expand Down
8 changes: 4 additions & 4 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ export const blankRealNImplied = () => {
};

export const [BC_I_AUNT, BC_I_COUSIN, BC_I_SIBLING_1, BC_I_SIBLING_2] = [
"Aunt/Uncle",
"Cousin",
"Sibling 1",
"Sibling 2",
"BC-Aunt",
"BC-Cousin",
"BC-Sibling-1",
"BC-Sibling-2",
];

export const [
Expand Down
2 changes: 2 additions & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ export interface internalLinkObj {
alt: string | null;
order: number;
parent?: string;
implied: string;
}

export interface SquareProps {
Expand Down Expand Up @@ -270,6 +271,7 @@ export type SquareItem = {
to: string;
real: boolean;
field: string;
implied?: string;
};

export interface MetaeditApi {
Expand Down
19 changes: 12 additions & 7 deletions src/sharedFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,16 @@ export function getRealnImplied(
dir: Directions = null
): RealNImplied {
const realsnImplieds: RealNImplied = blankRealNImplied();
const { userHiers } = plugin.settings;
const { mainG } = plugin;

if (!mainG.hasNode(currNode)) return realsnImplieds;
mainG.forEachEdge(currNode, (k, a, s, t) => {
const { field, dir: edgeDir } = a as { field: string; dir: Directions };
const { settings, closedG } = plugin;
const { userHiers } = settings;

if (!closedG.hasNode(currNode)) return realsnImplieds;
closedG.forEachEdge(currNode, (k, a, s, t) => {
const {
field,
dir: edgeDir,
implied,
} = a as { field: string; dir: Directions; implied?: string };
const oppField =
getOppFields(userHiers, field)[0] ?? fallbackOppField(field, edgeDir);

Expand All @@ -279,7 +283,7 @@ export function getRealnImplied(
if (s === currNode && (edgeDir === currDir || edgeDir === oppDir)) {
const arr = realsnImplieds[edgeDir].reals;
if (arr.findIndex((item) => item.to === t) === -1) {
arr.push({ to: t, real: true, field });
arr.push({ to: t, real: true, field, implied });
}
}
// Implieds
Expand All @@ -291,6 +295,7 @@ export function getRealnImplied(
to: s,
real: false,
field: oppField,
implied,
});
}
}
Expand Down

0 comments on commit 4572689

Please sign in to comment.