Skip to content

Commit

Permalink
fix(LinkNote): 🐛 Null check on links and embeds
Browse files Browse the repository at this point in the history
  • Loading branch information
SkepticMystic committed Nov 29, 2021
1 parent 1b3e8ef commit 18975b5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?? [])];

Expand Down

0 comments on commit 18975b5

Please sign in to comment.