Add error on duplicate plugin load
This commit is contained in:
parent
91f49d6997
commit
10fdc938c5
1 changed files with 12 additions and 0 deletions
|
|
@ -43,6 +43,14 @@ export default class VaultLinkPlugin extends Plugin {
|
|||
|
||||
public async onload(): Promise<void> {
|
||||
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();
|
||||
|
||||
this.registerObsidianExtensions(client);
|
||||
|
|
@ -188,6 +196,10 @@ export default class VaultLinkPlugin extends Plugin {
|
|||
this.register(() => {
|
||||
editorStatusDisplayManager.dispose();
|
||||
});
|
||||
|
||||
this.register(() => {
|
||||
(globalThis as any).VAULT_LINK_RUNNING_INSTANCE = null;
|
||||
});
|
||||
}
|
||||
|
||||
private addRibbonIcons(): void {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue