mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-03-27 04:05:18 +00:00
- Rewrite the service's binding/handler assignment systems - Removed loopholes that allowed traversal between services to clarify dependencies. - Consolidated the hidden state-related state, the handler, and the addition of bindings to the handler into a single object. - Currently, functions that can have handlers added implement either addHandler or setHandler directly on the function itself. I understand there are differing opinions on this, but for now, this is how it stands. - Services now possess a Context. Please ensure each platform has a class that inherits from ServiceContext. - To permit services to be dynamically bound, the services themselves are now defined by interfaces.
36 lines
1.4 KiB
TypeScript
36 lines
1.4 KiB
TypeScript
import { ObsidianLiveSyncSettingTab } from "./SettingDialogue/ObsidianLiveSyncSettingTab.ts";
|
|
import { AbstractObsidianModule } from "../AbstractObsidianModule.ts";
|
|
// import { PouchDB } from "../../lib/src/pouchdb/pouchdb-browser";
|
|
import { EVENT_REQUEST_OPEN_SETTING_WIZARD, EVENT_REQUEST_OPEN_SETTINGS, eventHub } from "../../common/events.ts";
|
|
|
|
export class ModuleObsidianSettingDialogue extends AbstractObsidianModule {
|
|
settingTab!: ObsidianLiveSyncSettingTab;
|
|
|
|
_everyOnloadStart(): Promise<boolean> {
|
|
this.settingTab = new ObsidianLiveSyncSettingTab(this.app, this.plugin);
|
|
this.plugin.addSettingTab(this.settingTab);
|
|
eventHub.onEvent(EVENT_REQUEST_OPEN_SETTINGS, () => this.openSetting());
|
|
eventHub.onEvent(EVENT_REQUEST_OPEN_SETTING_WIZARD, () => {
|
|
this.openSetting();
|
|
void this.settingTab.enableMinimalSetup();
|
|
});
|
|
|
|
return Promise.resolve(true);
|
|
}
|
|
|
|
openSetting() {
|
|
// Undocumented API
|
|
//@ts-ignore
|
|
this.app.setting.open();
|
|
//@ts-ignore
|
|
this.app.setting.openTabById("obsidian-livesync");
|
|
}
|
|
|
|
get appId() {
|
|
return `${"appId" in this.app ? this.app.appId : ""}`;
|
|
}
|
|
onBindFunction(core: typeof this.plugin, services: typeof core.services): void {
|
|
services.appLifecycle.onInitialise.addHandler(this._everyOnloadStart.bind(this));
|
|
}
|
|
}
|