From 18975b5d3d339a9aa1901e175f379258415a24a8 Mon Sep 17 00:00:00 2001 From: Ross Keenan Date: Mon, 29 Nov 2021 10:15:26 +0200 Subject: [PATCH] fix(LinkNote): :bug: Null check on links and embeds --- main.js | 10 +++++----- src/main.ts | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/main.js b/main.js index f288d37b..4894891a 100644 --- a/main.js +++ b/main.js @@ -49436,16 +49436,16 @@ class BCPlugin extends require$$0.Plugin { addLinkNotesToGraph(eligableAlts, frontms, mainG) { const { userHiers } = this.settings; eligableAlts.forEach((altFile) => { - var _a, _b; + var _a, _b, _c, _d; const linkNoteFile = altFile.file; const linkNoteBasename = getDVBasename(linkNoteFile); let field = altFile[BC_LINK_NOTE]; if (typeof field !== "string" || !getFields(userHiers).includes(field)) return; - const links = (_a = this.app.metadataCache - .getFileCache(linkNoteFile)) === null || _a === void 0 ? void 0 : _a.links.map((l) => l.link.match(/[^#|]+/)[0]); - const embeds = (_b = this.app.metadataCache - .getFileCache(linkNoteFile)) === null || _b === void 0 ? void 0 : _b.embeds.map((l) => l.link.match(/[^#|]+/)[0]); + const links = (_b = (_a = this.app.metadataCache + .getFileCache(linkNoteFile)) === null || _a === void 0 ? void 0 : _a.links) === null || _b === void 0 ? void 0 : _b.map((l) => l.link.match(/[^#|]+/)[0]); + const embeds = (_d = (_c = this.app.metadataCache + .getFileCache(linkNoteFile)) === null || _c === void 0 ? void 0 : _c.embeds) === null || _d === void 0 ? void 0 : _d.map((l) => l.link.match(/[^#|]+/)[0]); const targets = [...(links !== null && links !== void 0 ? links : []), ...(embeds !== null && embeds !== void 0 ? embeds : [])]; for (const target of targets) { const sourceOrder = this.getSourceOrder(altFile); diff --git a/src/main.ts b/src/main.ts index f9519cc7..aa72b156 100644 --- a/src/main.ts +++ b/src/main.ts @@ -889,11 +889,11 @@ export default class BCPlugin extends Plugin { const links = this.app.metadataCache .getFileCache(linkNoteFile) - ?.links.map((l) => l.link.match(/[^#|]+/)[0]); + ?.links?.map((l) => l.link.match(/[^#|]+/)[0]); const embeds = this.app.metadataCache .getFileCache(linkNoteFile) - ?.embeds.map((l) => l.link.match(/[^#|]+/)[0]); + ?.embeds?.map((l) => l.link.match(/[^#|]+/)[0]); const targets = [...(links ?? []), ...(embeds ?? [])];