From 489c3c338819eafd23c97e032fffb055bfd315f7 Mon Sep 17 00:00:00 2001 From: Ross Keenan Date: Thu, 18 Nov 2021 12:48:54 +0200 Subject: [PATCH] fix: :bug: More silent fails if no next/prev yet --- src/sharedFunctions.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/sharedFunctions.ts b/src/sharedFunctions.ts index f1f056f8..f8261832 100644 --- a/src/sharedFunctions.ts +++ b/src/sharedFunctions.ts @@ -349,8 +349,7 @@ export async function getNeighbourObjArr( current: TFile; hierarchies: HierarchyFields[]; }[] = fileFrontmatterArr.map((fileFrontmatter) => { - const currFileName = - fileFrontmatter.file.basename || fileFrontmatter.file.name; + const currNode = fileFrontmatter.file.basename || fileFrontmatter.file.name; const hierFields: { current: TFile; hierarchies: HierarchyFields[]; @@ -359,7 +358,7 @@ export async function getNeighbourObjArr( hierarchies: [], }; - userHierarchies.forEach((hier, i) => { + userHierarchies.forEach((hier) => { const fieldsArr = Object.values(hier) as [string[], string[], string[]]; const newHier: HierarchyFields = { up: {}, @@ -372,7 +371,7 @@ export async function getNeighbourObjArr( // Add regular metadata links if (settings.useAllMetadata) { DIRECTIONS.forEach((dir, i) => { - fieldsArr[i].forEach((field) => { + fieldsArr[i]?.forEach((field) => { newHier[dir][field] = getFieldValues( fileFrontmatter, field, @@ -384,13 +383,13 @@ export async function getNeighbourObjArr( // Add Juggl Links if (jugglLinks.length) { - const jugglLinksInFile = jugglLinks.filter((jugglLink) => { - return jugglLink.note === currFileName; - })[0]; + const jugglLinksInFile = jugglLinks.find((jugglLink) => { + return jugglLink.note === currNode; + }); if (jugglLinksInFile) { jugglLinksInFile.links.forEach((line) => { - if ((hier[line.dir] as string[]).includes(line.type)) { + if ((hier[line.dir] as string[])?.includes(line.type)) { newHier[line.dir][line.type] = [ ...new Set([ ...(newHier[line.dir][line.type] ?? []),