diff --git a/src/BreadcrumbsSettingTab.ts b/src/BreadcrumbsSettingTab.ts index 5783bea5..16a8aace 100644 --- a/src/BreadcrumbsSettingTab.ts +++ b/src/BreadcrumbsSettingTab.ts @@ -219,6 +219,29 @@ export class BreadcrumbsSettingTab extends PluginSettingTab { }) ); + if (this.app.plugins.plugins.dataview !== undefined) { + new Setting(generalDetails) + .setName("Dataview Wait Time") + .setDesc( + 'Enter an integer number of seconds to wait for the Dataview Index to load. The larger your vault, the longer it will take. If you see an error in the console saying "Cannot destructure currGraphs of undefined", try making this time longer. If you don\'t get that error, you can make this time shorter to make the Breadcrumbs load faster. The default is 5 seconds.' + ) + .addText((text) => + text + .setPlaceholder("Seconds") + .setValue((plugin.settings.dvWaitTime / 1000).toString()) + .onChange(async (value) => { + const num = Number(value); + + if (num > 0) { + plugin.settings.dvWaitTime = num * 1000; + await plugin.saveSettings(); + } else { + new Notice("The interval must be a non-negative number"); + } + }) + ); + } + new Setting(generalDetails) .setName("Refresh Interval") .setDesc( diff --git a/src/MatrixView.ts b/src/MatrixView.ts index 9784f209..20d2d61a 100644 --- a/src/MatrixView.ts +++ b/src/MatrixView.ts @@ -1,8 +1,7 @@ -import type { Edge, Graph } from "graphlib"; -import { cloneDeep, sum } from "lodash"; +import type { Graph } from "graphlib"; +import { cloneDeep } from "lodash"; import { ItemView, TFile, WorkspaceLeaf } from "obsidian"; import { - DATAVIEW_INDEX_DELAY, DIRECTIONS, TRAIL_ICON, VIEW_TYPE_BREADCRUMBS_MATRIX, @@ -40,7 +39,10 @@ export default class MatrixView extends ItemView { this.matrixQ = this.plugin.settings.defaultView; this.app.workspace.onLayoutReady(async () => { - setTimeout(async () => await this.draw(), DATAVIEW_INDEX_DELAY); + setTimeout( + async () => await this.draw(), + this.plugin.settings.dvWaitTime + ); }); this.plugin.addCommand({ @@ -345,19 +347,28 @@ export default class MatrixView extends ItemView { const upSquare: SquareProps = { realItems: rUp, impliedItems: iUp, - fieldName: hier.up[0] === "" ? "" : hier.up.join(", "), + fieldName: + hier.up[0] === "" + ? `${hier.down.join(",")}` + : hier.up.join(", "), }; const sameSquare: SquareProps = { realItems: rSame, impliedItems: iSameArr, - fieldName: hier.same[0] === "" ? "" : hier.same.join(", "), + fieldName: + hier.same[0] === "" + ? `${hier.up.join(",")}` + : hier.same.join(", "), }; const downSquare: SquareProps = { realItems: rDown, impliedItems: iDown, - fieldName: hier.down[0] === "" ? "" : hier.down.join(", "), + fieldName: + hier.down[0] === "" + ? `${hier.up.join(",")}` + : hier.down.join(", "), }; return [upSquare, sameSquare, downSquare]; diff --git a/src/StatsView.ts b/src/StatsView.ts index b0ada018..178bfbb7 100644 --- a/src/StatsView.ts +++ b/src/StatsView.ts @@ -1,9 +1,6 @@ import type { Graph } from "graphlib"; import { ItemView, WorkspaceLeaf } from "obsidian"; -import { - DATAVIEW_INDEX_DELAY, - VIEW_TYPE_BREADCRUMBS_STATS, -} from "src/constants"; +import { VIEW_TYPE_BREADCRUMBS_STATS } from "src/constants"; import type BreadcrumbsPlugin from "src/main"; import Stats from "./Components/Stats.svelte"; @@ -20,7 +17,10 @@ export default class StatsView extends ItemView { super.onload(); await this.plugin.saveSettings(); this.app.workspace.onLayoutReady(async () => { - setTimeout(async () => await this.draw(), DATAVIEW_INDEX_DELAY); + setTimeout( + async () => await this.draw(), + this.plugin.settings.dvWaitTime + ); }); } diff --git a/src/constants.ts b/src/constants.ts index c6053a3c..5ccd5866 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -10,8 +10,6 @@ export const TRAIL_ICON_SVG = export const splitLinksRegex = new RegExp(/\[\[(.+?)\]\]/g); export const dropHeaderOrAlias = new RegExp(/\[\[([^#|]+)\]\]/); -export const DATAVIEW_INDEX_DELAY = 5000; - export const VISTYPES: visTypes[] = [ "Force Directed Graph", "Tidy Tree", diff --git a/src/interfaces.ts b/src/interfaces.ts index 8c063db6..f5650300 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -5,6 +5,7 @@ export interface BreadcrumbsSettings { userHierarchies: userHierarchy[]; indexNote: string[]; refreshIndexOnActiveLeafChange: boolean; + dvWaitTime: number; refreshIntervalTime: number; defaultView: boolean; showNameOrType: boolean; diff --git a/src/main.ts b/src/main.ts index 094167bb..f39d6c3a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2,7 +2,6 @@ import { Graph } from "graphlib"; import { addIcon, MarkdownView, Plugin, TFile, WorkspaceLeaf } from "obsidian"; import { BreadcrumbsSettingTab } from "src/BreadcrumbsSettingTab"; import { - DATAVIEW_INDEX_DELAY, DIRECTIONS, TRAIL_ICON, TRAIL_ICON_SVG, @@ -14,7 +13,6 @@ import type { Directions, dvFrontmatterCache, HierarchyGraphs, - relObj, } from "src/interfaces"; import MatrixView from "src/MatrixView"; import { @@ -25,7 +23,6 @@ import { getNeighbourObjArr, getObsMetadataCache, mergeGs, - splitAndTrim, } from "src/sharedFunctions"; import StatsView from "src/StatsView"; import { VisModal } from "src/VisModal"; @@ -36,6 +33,7 @@ const DEFAULT_SETTINGS: BreadcrumbsSettings = { userHierarchies: [], indexNote: [""], refreshIndexOnActiveLeafChange: false, + dvWaitTime: 5000, refreshIntervalTime: 0, defaultView: true, showNameOrType: true, @@ -160,7 +158,7 @@ export default class BreadcrumbsPlugin extends Plugin { }, this.settings.refreshIntervalTime * 1000); this.registerInterval(this.refreshIntervalID); } - }, DATAVIEW_INDEX_DELAY); + }, this.settings.dvWaitTime); }); addIcon(TRAIL_ICON, TRAIL_ICON_SVG);