Various improvements #169
1 changed files with 12 additions and 0 deletions
Add error on duplicate plugin load
commit
a2b652559b
|
|
@ -43,6 +43,14 @@ export default class VaultLinkPlugin extends Plugin {
|
||||||
|
|
||||||
public async onload(): Promise<void> {
|
public async onload(): Promise<void> {
|
||||||
this.app.workspace.onLayoutReady(async () => {
|
this.app.workspace.onLayoutReady(async () => {
|
||||||
|
if ((globalThis as any).VAULT_LINK_RUNNING_INSTANCE) {
|
||||||
|
new Notice(
|
||||||
|
"Another instance of VaultLink is already running. Please disable the duplicate instance."
|
||||||
|
);
|
||||||
|
throw new Error("VaultLink instance already running");
|
||||||
|
}
|
||||||
|
(globalThis as any).VAULT_LINK_RUNNING_INSTANCE = this;
|
||||||
|
|
||||||
const client = await this.createSyncClient();
|
const client = await this.createSyncClient();
|
||||||
|
|
||||||
this.registerObsidianExtensions(client);
|
this.registerObsidianExtensions(client);
|
||||||
|
|
@ -188,6 +196,10 @@ export default class VaultLinkPlugin extends Plugin {
|
||||||
this.register(() => {
|
this.register(() => {
|
||||||
editorStatusDisplayManager.dispose();
|
editorStatusDisplayManager.dispose();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.register(() => {
|
||||||
|
(globalThis as any).VAULT_LINK_RUNNING_INSTANCE = null;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private addRibbonIcons(): void {
|
private addRibbonIcons(): void {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue