From eb6f7d5a58a6a781265f7d5184f41cbf2e4ea82e Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Sat, 11 Jan 2025 10:53:15 +0000 Subject: [PATCH] Reorder initialization --- plugin/src/vault-link-plugin.ts | 44 ++++++++++++++++----------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/plugin/src/vault-link-plugin.ts b/plugin/src/vault-link-plugin.ts index b524f1c2..ef1b81e0 100644 --- a/plugin/src/vault-link-plugin.ts +++ b/plugin/src/vault-link-plugin.ts @@ -2,7 +2,7 @@ import type { WorkspaceLeaf } from "obsidian"; import { Plugin } from "obsidian"; import "./styles.scss"; import "../manifest.json"; -import init, { setPanicHook } from "sync_lib"; +import init from "sync_lib"; import wasmBin from "sync_lib/sync_lib_bg.wasm"; import { SyncSettingsTab } from "./views/settings-tab"; import { HistoryView } from "./views/history-view"; @@ -32,8 +32,6 @@ export default class VaultLinkPlugin extends Plugin { (wasmBin as any).default // it is loaded as a base64 string by webpack ); - setPanicHook(); - const database = new Database( await this.loadData(), this.saveData.bind(this) @@ -67,6 +65,26 @@ export default class VaultLinkPlugin extends Plugin { new StatusBar(database, this, this.history, syncer); + this.registerView( + HistoryView.TYPE, + (leaf) => new HistoryView(leaf, database, this.history) + ); + this.registerView( + LogsView.TYPE, + (leaf) => new LogsView(this, database, leaf) + ); + + this.addRibbonIcon( + HistoryView.ICON, + "Open VaultLink events", + async (_: MouseEvent) => this.activateView(HistoryView.TYPE) + ); + this.addRibbonIcon( + LogsView.ICON, + "Open VaultLink logs", + async (_: MouseEvent) => this.activateView(LogsView.TYPE) + ); + const eventHandler = new ObsidianFileEventHandler(syncer); this.app.workspace.onLayoutReady(async () => { @@ -119,26 +137,6 @@ export default class VaultLinkPlugin extends Plugin { } }); - this.registerView( - HistoryView.TYPE, - (leaf) => new HistoryView(leaf, database, this.history) - ); - this.registerView( - LogsView.TYPE, - (leaf) => new LogsView(this, database, leaf) - ); - - this.addRibbonIcon( - HistoryView.ICON, - "Open VaultLink events", - async (_: MouseEvent) => this.activateView(HistoryView.TYPE) - ); - this.addRibbonIcon( - LogsView.ICON, - "Open VaultLink logs", - async (_: MouseEvent) => this.activateView(LogsView.TYPE) - ); - Logger.getInstance().info("Plugin loaded"); }