From 3b1309fe4be2f83e373753d86a7d56926b365a04 Mon Sep 17 00:00:00 2001 From: Ross Keenan Date: Mon, 22 Nov 2021 07:55:56 +0200 Subject: [PATCH] refactor: :fire: Remove refreshIndexInterval --- src/BreadcrumbsSettingTab.ts | 78 ++++++++++++++++++------------------ src/constants.ts | 4 +- src/interfaces.ts | 4 +- src/main.ts | 21 +++++----- 4 files changed, 53 insertions(+), 54 deletions(-) diff --git a/src/BreadcrumbsSettingTab.ts b/src/BreadcrumbsSettingTab.ts index fdc2978b..72803b1d 100644 --- a/src/BreadcrumbsSettingTab.ts +++ b/src/BreadcrumbsSettingTab.ts @@ -133,9 +133,9 @@ export class BCSettingTab extends PluginSettingTab { ) .addToggle((toggle) => toggle - .setValue(settings.refreshIndexOnActiveLeafChange) + .setValue(settings.refreshOnNoteChange) .onChange(async (value) => { - settings.refreshIndexOnActiveLeafChange = value; + settings.refreshOnNoteChange = value; await plugin.saveSettings(); }) ); @@ -207,43 +207,43 @@ export class BCSettingTab extends PluginSettingTab { ); } - new Setting(generalDetails) - .setName("Refresh Interval") - .setDesc( - "Enter an integer number of seconds to wait before Breadcrumbs auto-refreshes its data. This would update the matrix view and the trail if either are affected. (Set to 0 to disable autorefreshing)" - ) - .addText((text) => - text - .setPlaceholder("Seconds") - .setValue(settings.refreshIntervalTime.toString()) - .onChange(async (value) => { - clearInterval(plugin.refreshIntervalID); - const num = Number(value); - - if (num > 0) { - settings.refreshIntervalTime = num; - await plugin.saveSettings(); - - plugin.refreshIntervalID = window.setInterval(async () => { - plugin.mainG = await plugin.initGraphs(); - if (settings.showTrail) { - await plugin.drawTrail(); - } - const activeMatrix = plugin.getActiveTYPEView(MATRIX_VIEW); - if (activeMatrix) { - await activeMatrix.draw(); - } - }, num * 1000); - plugin.registerInterval(plugin.refreshIntervalID); - } else if (num === 0) { - settings.refreshIntervalTime = num; - await plugin.saveSettings(); - clearInterval(plugin.refreshIntervalID); - } else { - new Notice("The interval must be a non-negative number"); - } - }) - ); + // new Setting(generalDetails) + // .setName("Refresh Interval") + // .setDesc( + // "Enter an integer number of seconds to wait before Breadcrumbs auto-refreshes its data. This would update the matrix view and the trail if either are affected. (Set to 0 to disable autorefreshing)" + // ) + // .addText((text) => + // text + // .setPlaceholder("Seconds") + // .setValue(settings.refreshIntervalTime.toString()) + // .onChange(async (value) => { + // clearInterval(plugin.refreshIntervalID); + // const num = Number(value); + + // if (num > 0) { + // settings.refreshIntervalTime = num; + // await plugin.saveSettings(); + + // plugin.refreshIntervalID = window.setInterval(async () => { + // plugin.mainG = await plugin.initGraphs(); + // if (settings.showTrail) { + // await plugin.drawTrail(); + // } + // const activeMatrix = plugin.getActiveTYPEView(MATRIX_VIEW); + // if (activeMatrix) { + // await activeMatrix.draw(); + // } + // }, num * 1000); + // plugin.registerInterval(plugin.refreshIntervalID); + // } else if (num === 0) { + // settings.refreshIntervalTime = num; + // await plugin.saveSettings(); + // clearInterval(plugin.refreshIntervalID); + // } else { + // new Notice("The interval must be a non-negative number"); + // } + // }) + // ); const MLViewDetails: HTMLDetailsElement = containerEl.createEl("details"); MLViewDetails.createEl("summary", { text: "Matrix/List View" }); diff --git a/src/constants.ts b/src/constants.ts index 10231d16..976d2b0d 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -98,10 +98,10 @@ export const DEFAULT_SETTINGS: BCSettings = { indexNotes: [""], hierarchyNotes: [""], HNUpField: "", - refreshIndexOnActiveLeafChange: false, + refreshOnNoteChange: false, useAllMetadata: true, parseJugglLinksWithoutJuggl: false, - refreshIntervalTime: 0, + // refreshIntervalTime: 0, orderField: "order", showNameOrType: true, showRelationType: true, diff --git a/src/interfaces.ts b/src/interfaces.ts index bf166310..36b5eccf 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -26,8 +26,8 @@ export interface BCSettings { noPathMessage: string; orderField: string; parseJugglLinksWithoutJuggl: boolean; - refreshIndexOnActiveLeafChange: boolean; - refreshIntervalTime: number; + refreshOnNoteChange: boolean; + // refreshIntervalTime: number; respectReadableLineLength: boolean; showNameOrType: boolean; showRelationType: boolean; diff --git a/src/main.ts b/src/main.ts index 5ced2fcb..7feb2654 100644 --- a/src/main.ts +++ b/src/main.ts @@ -80,7 +80,7 @@ export default class BCPlugin extends Plugin { this.activeLeafChange = this.app.workspace.on( "active-leaf-change", async () => { - if (this.settings.refreshIndexOnActiveLeafChange) { + if (this.settings.refreshOnNoteChange) { await this.refreshIndex(); } else { const activeView = this.getActiveTYPEView(MATRIX_VIEW); @@ -105,17 +105,16 @@ export default class BCPlugin extends Plugin { this.registerActiveLeafEvent(); - // ANCHOR autorefresh interval - if (settings.refreshIntervalTime > 0) { - this.refreshIntervalID = window.setInterval(async () => { - this.mainG = await this.initGraphs(); - if (settings.showBCs) await this.drawTrail(); + // if (settings.refreshIntervalTime > 0) { + // this.refreshIntervalID = window.setInterval(async () => { + // this.mainG = await this.initGraphs(); + // if (settings.showBCs) await this.drawTrail(); - const activeView = this.getActiveTYPEView(MATRIX_VIEW); - if (activeView) await activeView.draw(); - }, settings.refreshIntervalTime * 1000); - this.registerInterval(this.refreshIntervalID); - } + // const activeView = this.getActiveTYPEView(MATRIX_VIEW); + // if (activeView) await activeView.draw(); + // }, settings.refreshIntervalTime * 1000); + // this.registerInterval(this.refreshIntervalID); + // } }; async onload(): Promise {