fix: update graph on settings change (#4)

This commit is contained in:
Kritagya Bhattarai (CalfMoon) 2025-03-28 17:28:56 +05:45
parent b23deebdf5
commit c5739de84c
2 changed files with 11 additions and 4 deletions

View file

@ -40,16 +40,16 @@ export default class NodeFactor extends Plugin {
// clear cache when there is change in the vault
this.registerEvent(
this.app.vault.on("create", () => (this.storedSized = [])),
this.app.vault.on("create", () => this.clearSizeCache()),
);
this.registerEvent(
this.app.vault.on("modify", () => (this.storedSized = [])),
this.app.vault.on("modify", () => this.clearSizeCache()),
);
this.registerEvent(
this.app.vault.on("delete", () => (this.storedSized = [])),
this.app.vault.on("delete", () => this.clearSizeCache()),
);
this.registerEvent(
this.app.vault.on("rename", () => (this.storedSized = [])),
this.app.vault.on("rename", () => this.clearSizeCache()),
);
}
@ -128,6 +128,10 @@ export default class NodeFactor extends Plugin {
return size;
}
clearSizeCache() {
this.storedSized = [];
}
async loadSettings() {
this.settings = Object.assign(
{},

View file

@ -23,6 +23,7 @@ export default class NodeFactorSettingTab extends PluginSettingTab {
.setDynamicTooltip()
.setValue(this.plugin.settings.fwdMultiplier)
.onChange(async (value) => {
this.plugin.clearSizeCache();
this.plugin.settings.fwdMultiplier = value;
await this.plugin.saveSettings();
}),
@ -35,6 +36,7 @@ export default class NodeFactorSettingTab extends PluginSettingTab {
toggle
.setValue(this.plugin.settings.fwdTree)
.onChange(async (value) => {
this.plugin.clearSizeCache();
this.plugin.settings.fwdTree = value;
await this.plugin.saveSettings();
}),
@ -49,6 +51,7 @@ export default class NodeFactorSettingTab extends PluginSettingTab {
.setDynamicTooltip()
.setValue(this.plugin.settings.bwdMultiplier)
.onChange(async (value) => {
this.plugin.clearSizeCache();
this.plugin.settings.bwdMultiplier = value;
await this.plugin.saveSettings();
}),