mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-06-10 16:30:15 +00:00
0dfd42259d
Now, Self-hosted LiveSync has finally begun to be split into the Self-hosted LiveSync plugin for Obsidian, and a properly abstracted version of it. This may not offer much benefit to Obsidian plugin users, or might even cause a slight inconvenience, but I believe it will certainly help improve testability and make the ecosystem better. However, I do not see the point in putting something with little benefit into beta, so I am handling this on the alpha branch. I would actually preferred to create an R&D branch, but I was not keen on the ampersand, and I feel it will eventually become a proper beta anyway. ### Refactored - Separated `ObsidianLiveSyncPlugin` into `ObsidianLiveSyncPlugin` and `LiveSyncBaseCore`. - Now `LiveSyncCore` indicates the type specified version of `LiveSyncBaseCore`. - Referencing `plugin.xxx` has been rewritten to referencing the corresponding service or `core.xxx`. ### Internal API changes - Storage Access APIs are now yielding Promises. This is to allow more limited storage platforms to be supported. ### R&D - Browser-version of Self-hosted LiveSync is now in development. This is not intended for public use now, but I will eventually make it available for testing. - We can see the code in `src/apps/webapp` for the browser version.
37 lines
1.4 KiB
TypeScript
37 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";
|
|
import type { LiveSyncCore } from "@/main.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 : ""}`;
|
|
}
|
|
override onBindFunction(core: LiveSyncCore, services: typeof core.services): void {
|
|
services.appLifecycle.onInitialise.addHandler(this._everyOnloadStart.bind(this));
|
|
}
|
|
}
|