From 79bbabee97c5de4c9351ef0bdeb64d49e93ac7d3 Mon Sep 17 00:00:00 2001 From: zsviczian Date: Sun, 29 Oct 2023 21:24:47 +0100 Subject: [PATCH] 0.2.11 --- manifest.json | 2 +- src/utils/dataview.ts | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/manifest.json b/manifest.json index 4d659d6..72b3091 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "excalibrain", "name": "ExcaliBrain", - "version": "0.2.10", + "version": "0.2.11", "minAppVersion": "1.1.6", "description": "A clean, intuitive and editable graph view for Obsidian", "author": "Zsolt Viczian", diff --git a/src/utils/dataview.ts b/src/utils/dataview.ts index 890b881..2ceedec 100644 --- a/src/utils/dataview.ts +++ b/src/utils/dataview.ts @@ -72,9 +72,10 @@ const readDVField = (app: App, field: any, file:TFile):string[] => { //! currently there is an issue with case sensitivity. DataView retains case sensitivity of links for the front matter, but not the others const objectLinks:string[] = values .filter((l:any) => l?.values && typeof l === "object" && typeof l.values[0] === "string") - .map((l:any)=>getPathOrSelf(app,l.values[0],file.path)) + ?.map((l:any)=>getPathOrSelf(app,l.values[0],file.path)) - return Array.from(res).concat(stringLinks).concat(objectLinks); + if(!objectLinks) console.log({error: "objectLinks is undefined which is unexpected",errorLocation:"readDVField", field, file}); + return Array.from(res).concat(stringLinks).concat(objectLinks??[]); } //the field is a single link @@ -115,9 +116,9 @@ export const getPrimaryTag = ( if(dvPage[settings.primaryTagFieldLowerCase]) { const tags = dvPage[settings.primaryTagFieldLowerCase] .match(/#([^\s\])$"'\\]*)(?:$|\s)/g) - .map((match:string) => match.trim()) + ?.map((match:string) => match.trim()) .filter((t:string)=>settings.tagStyleList.some(x=>t.startsWith(x))); - const styleTag = (tags.length > 0) ? tags[0] : pageTags[0]; + const styleTag = tags && (tags.length > 0) ? tags[0] : pageTags[0]; return [styleTag, pageTags.filter(t=>t!=styleTag)]; } return [pageTags[0], pageTags.slice(1)]; @@ -146,7 +147,7 @@ export const getTagStyle = ( const prefixSet = new Set(); if(style.prefix) prefixSet.add(style.prefix); keys - .map(key=>settings.tagNodeStyles[key].prefix).filter(x=>Boolean(x)) + ?.map(key=>settings.tagNodeStyles[key].prefix).filter(x=>Boolean(x)) .forEach(x=>prefixSet.add(x)); const prefix = Array.from(prefixSet).join(""); return {