Add open settings

This commit is contained in:
Andras Schmelczer 2025-01-02 17:44:03 +00:00
parent 4fd74e0d9f
commit e15fc63e79
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C

View file

@ -21,6 +21,7 @@ export default class SyncPlugin extends Plugin {
private remoteListenerIntervalId: number | null = null; private remoteListenerIntervalId: number | null = null;
private readonly operations = new ObsidianFileOperations(this.app.vault); private readonly operations = new ObsidianFileOperations(this.app.vault);
private readonly history = new SyncHistory(); private readonly history = new SyncHistory();
private settingsTab: SyncSettingsTab;
public async onload(): Promise<void> { public async onload(): Promise<void> {
Logger.getInstance().info("Starting plugin"); Logger.getInstance().info("Starting plugin");
@ -48,11 +49,16 @@ export default class SyncPlugin extends Plugin {
history: this.history, history: this.history,
}); });
this.addSettingTab( this.settingsTab = new SyncSettingsTab(
new SyncSettingsTab(this.app, this, database, syncServer, syncer) 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); 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<void> { private async activateView(type: string): Promise<void> {
const { workspace } = this.app; const { workspace } = this.app;