From e15fc63e794ca04f872ff3cc268ea8983f9ae938 Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Thu, 2 Jan 2025 17:44:03 +0000 Subject: [PATCH] Add open settings --- plugin/src/plugin.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/plugin/src/plugin.ts b/plugin/src/plugin.ts index 41c1425..520288e 100644 --- a/plugin/src/plugin.ts +++ b/plugin/src/plugin.ts @@ -21,6 +21,7 @@ export default class SyncPlugin extends Plugin { private remoteListenerIntervalId: number | null = null; private readonly operations = new ObsidianFileOperations(this.app.vault); private readonly history = new SyncHistory(); + private settingsTab: SyncSettingsTab; public async onload(): Promise { Logger.getInstance().info("Starting plugin"); @@ -48,11 +49,16 @@ export default class SyncPlugin extends Plugin { history: this.history, }); - this.addSettingTab( - new SyncSettingsTab(this.app, this, database, syncServer, syncer) + this.settingsTab = new SyncSettingsTab( + this.app, + this, + database, + syncServer, + syncer ); + this.addSettingTab(this.settingsTab); - new StatusBar(this, this.history, syncer); + new StatusBar(database, this, this.history, syncer); const eventHandler = new ObsidianFileEventHandler(syncer); @@ -132,6 +138,13 @@ export default class SyncPlugin extends Plugin { } } + public openSettings() { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this.app as any).setting.open(); // this is undocumented + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this.app as any).setting.openTab(this.settingsTab); // this is undocumented + } + private async activateView(type: string): Promise { const { workspace } = this.app;