From a370041e2f260a12955a05b5a96271974633fab4 Mon Sep 17 00:00:00 2001 From: Simon Cambier Date: Sat, 18 May 2024 22:54:12 +0200 Subject: [PATCH] Quick hack for global app --- src/main.ts | 11 +++++++---- src/stores/obsidian-app.ts | 4 +++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main.ts b/src/main.ts index 571a38d..fe00b8b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,4 +1,4 @@ -import { App, Notice, Platform, Plugin } from 'obsidian' +import { App, Notice, Platform, Plugin, type PluginManifest } from 'obsidian' import { OmnisearchInFileModal, OmnisearchVaultModal, @@ -14,14 +14,13 @@ import { import { eventBus, EventNames, - getTextExtractor, indexingStep, IndexingStepType, isCacheEnabled, } from './globals' import api, { notifyOnIndexed } from './tools/api' import { isFileIndexable, logDebug } from './tools/utils' -import { database, OmnisearchCache } from './database' +import { OmnisearchCache, database } from './database' import * as NotesIndex from './notes-index' import { searchEngine } from './search/omnisearch' import { cacheManager } from './cache-manager' @@ -32,8 +31,12 @@ export default class OmnisearchPlugin extends Plugin { public apiHttpServer: null | any = null private ribbonButton?: HTMLElement - async onload(): Promise { + constructor(app: App, manifest: PluginManifest) { + super(app, manifest) setObsidianApp(this.app) + } + + async onload(): Promise { await loadSettings(this) this.addSettingTab(new SettingsTab(this)) diff --git a/src/stores/obsidian-app.ts b/src/stores/obsidian-app.ts index f9984d5..27885c3 100644 --- a/src/stores/obsidian-app.ts +++ b/src/stores/obsidian-app.ts @@ -11,7 +11,9 @@ export function setObsidianApp(app: App) { */ export function getObsidianApp() { if (!obsidianApp) { - throw new Error('Obsidian app not set') + // throw new Error('Obsidian app not set') + // console.trace('Obsidian app not set') + return app // FIXME: please. } return obsidianApp as App }