From caffbbb5c1bbb51a314fa2f29084b3c17c49cf55 Mon Sep 17 00:00:00 2001 From: Hananoshika Yomaru Date: Sat, 30 Dec 2023 10:43:54 -0800 Subject: [PATCH] update the setting manager init new view param --- src/views/graph/3dView/GlobalGraph3dView.ts | 5 ++++- src/views/graph/3dView/Graph3dView.ts | 12 ++++++------ src/views/graph/3dView/LocalGraph3dView.ts | 5 ++++- src/views/graph/3dView/PostProcessorGraph3dView.ts | 6 +++--- .../graphSettingManagers/GraphSettingsManager.ts | 11 ++++++++--- .../PostProcessorGraphSettingManager.ts | 9 --------- 6 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/views/graph/3dView/GlobalGraph3dView.ts b/src/views/graph/3dView/GlobalGraph3dView.ts index 718665f..7fca6e6 100644 --- a/src/views/graph/3dView/GlobalGraph3dView.ts +++ b/src/views/graph/3dView/GlobalGraph3dView.ts @@ -78,9 +78,12 @@ export class GlobalGraph3dView extends Graph3dView>; + } + /** + * 1. need to initialize force graph here but this class doesn't know how to initialize it + * 2. graph setting manager need to init a view here + */ + protected onReady(): void { // register event on event bus const parent = this.getParent(); parent.registerEvent( @@ -82,12 +88,6 @@ export abstract class Graph3dView< ); } - /** - * 1. need to initialize force graph here but this class doesn't know how to initialize it - * 2. graph setting manager need to init a view here - */ - protected abstract onReady(): void; - /** * get the current force graph object */ diff --git a/src/views/graph/3dView/LocalGraph3dView.ts b/src/views/graph/3dView/LocalGraph3dView.ts index 8e148eb..16b31e1 100644 --- a/src/views/graph/3dView/LocalGraph3dView.ts +++ b/src/views/graph/3dView/LocalGraph3dView.ts @@ -189,9 +189,12 @@ export class LocalGraph3dView extends Graph3dView { diff --git a/src/views/graph/3dView/PostProcessorGraph3dView.ts b/src/views/graph/3dView/PostProcessorGraph3dView.ts index 87cca6f..54442f9 100644 --- a/src/views/graph/3dView/PostProcessorGraph3dView.ts +++ b/src/views/graph/3dView/PostProcessorGraph3dView.ts @@ -74,14 +74,14 @@ export class PostProcessorGraph3dView extends Graph3dView< } onReady(): void { + super.onReady(); // first we need to create the force graph this.forceGraph = new ForceGraph( this as typeof this.forceGraph.view, getNewLocalGraph(this.plugin) ); + // post process graph will not have 3d graph // setting manager init view - this.settingManager.initNewView(true); - // init event handler on parent - this.parent.registerEvent(this.eventBus.on("open-node-preview", (node: Node) => {})); + // this.settingManager.initNewView(true); } } diff --git a/src/views/settings/graphSettingManagers/GraphSettingsManager.ts b/src/views/settings/graphSettingManagers/GraphSettingsManager.ts index d883aca..09a82db 100644 --- a/src/views/settings/graphSettingManagers/GraphSettingsManager.ts +++ b/src/views/settings/graphSettingManagers/GraphSettingsManager.ts @@ -89,7 +89,12 @@ export abstract class GraphSettingManager< /** * this function will initialize a new view for setting and then append it to the current graph view */ - initNewView(collapsed = false) { + initNewView( + config: { + collapsed?: boolean; + } = {} + ) { + const { collapsed = false } = config; // check if the contentEl of the graph View already contains the containerEl of setting manager, if not add it if (!this.graphView.contentEl.contains(this.containerEl)) { this.graphView.contentEl.appendChild(this.containerEl); @@ -228,7 +233,7 @@ export abstract class GraphSettingManager< PluginSettingManager.getNewSetting(this.graphView.graphType); }); - this.initNewView(false); + this.initNewView(); } public applySettings(newSetting: SavedSetting["setting"]) { @@ -243,7 +248,7 @@ export abstract class GraphSettingManager< // newSetting; }); - this.initNewView(false); + this.initNewView(); } /** diff --git a/src/views/settings/graphSettingManagers/PostProcessorGraphSettingManager.ts b/src/views/settings/graphSettingManagers/PostProcessorGraphSettingManager.ts index 32bf8f1..b2adfdd 100644 --- a/src/views/settings/graphSettingManagers/PostProcessorGraphSettingManager.ts +++ b/src/views/settings/graphSettingManagers/PostProcessorGraphSettingManager.ts @@ -16,15 +16,6 @@ export class PostProcessorGraphSettingManager extends GraphSettingManager< this.currentSetting = new State(PluginSettingManager.getNewSetting(GraphType.postProcessor)); } - // we need to override this because the underlying update method will update plugin setting - // instead of updating the plugin setting, we need to update the value in side the codeblock - updateCurrentSettings( - updateFunc: (setting: State) => void, - shouldUpdateGraphView?: boolean - ): MarkdownPostProcessorGraphSettings { - return this.currentSetting.value; - } - static new(parentView: PostProcessorGraph3dView) { const settingManager = new PostProcessorGraphSettingManager(parentView); settingManager.onReady();