diff --git a/src/Components/TrailGrid.svelte b/src/Components/TrailGrid.svelte index 6a47b97a..84823c95 100644 --- a/src/Components/TrailGrid.svelte +++ b/src/Components/TrailGrid.svelte @@ -4,8 +4,6 @@ import type BreadcrumbsPlugin from "src/main"; import { closeImpliedLinks, - getAllXGs, - mergeGs, normalise, openOrSwitch, padArray, diff --git a/src/main.ts b/src/main.ts index 73503d74..deb52000 100644 --- a/src/main.ts +++ b/src/main.ts @@ -21,13 +21,12 @@ import type { Directions, dvFrontmatterCache, HierarchyGraphs, - MergedGraphs, } from "src/interfaces"; import MatrixView from "src/MatrixView"; import { closeImpliedLinks, debug, - getAllXGs, + getAllGsInDir, getDVMetadataCache, getNeighbourObjArr, getObsMetadataCache, @@ -336,7 +335,7 @@ export default class BreadcrumbsPlugin extends Plugin { }); DIRECTIONS.forEach((dir) => { - const allXGs = getAllXGs(userHierarchies, graphs.hierGs, dir); + const allXGs = getAllGsInDir(userHierarchies, graphs.hierGs, dir); const dirMerged = mergeGs(...Object.values(allXGs)); graphs.mergedGs[dir] = dirMerged; }); diff --git a/src/sharedFunctions.ts b/src/sharedFunctions.ts index 48213001..2ff16a71 100644 --- a/src/sharedFunctions.ts +++ b/src/sharedFunctions.ts @@ -497,27 +497,34 @@ export function removeUnlinkedNodes(g: Graph) { return copy; } -export function getAllXGs( +export function getAllGsInDir( userHierarchies: userHierarchy[], currGraphs: HierarchyGraphs[], dir: Directions ) { - const fieldNamesInXDir = userHierarchies - .map((hier) => hier[dir]) - .filter((field) => field.join() !== "") - .flat(); - - const allXGs: { [rel: string]: Graph } = {}; - - currGraphs.forEach((hierarchyGs) => { - fieldNamesInXDir.forEach((field) => { - const graph = hierarchyGs[dir][field]; - if (graph) { - allXGs[field] = graph; - } - }); - }); - return allXGs; + const target = {}; + const allGsInDir: { [field: string]: Graph } = Object.assign( + target, + ...currGraphs.map((hierGs) => hierGs[dir]) + ); + + // const fieldNamesInXDir = userHierarchies + // .map((hier) => hier[dir]) + // .filter((field) => field.join() !== "") + // .flat(); + + // const allXGs: { [rel: string]: Graph } = {}; + + // currGraphs.forEach((hierarchyGs) => { + // fieldNamesInXDir.forEach((field) => { + // const graph = hierarchyGs[dir][field]; + // if (graph) { + // allXGs[field] = graph; + // } + // }); + // }); + // console.log({ allXGs, allGsInDir }); + return allGsInDir; } export function hierToStr(hier: userHierarchy) {