This commit is contained in:
Simon Cambier
2023-10-13 08:47:35 +02:00
parent fc6df5d36b
commit 9a218167d7
3 changed files with 70 additions and 51 deletions

View File

@@ -24,17 +24,23 @@ import { database, OmnisearchCache } from './database'
import * as NotesIndex from './notes-index'
import { searchEngine } from './search/omnisearch'
import { cacheManager } from './cache-manager'
import getServer from './tools/api-server'
export default class OmnisearchPlugin extends Plugin {
private ribbonButton?: HTMLElement
public apiHttpServer = getServer()
// FIXME: fix the type
public apiHttpServer: null | any = null
async onload(): Promise<void> {
await loadSettings(this)
this.addSettingTab(new SettingsTab(this))
if (!Platform.isMobile) {
import('./tools/api-server').then(m =>
this.apiHttpServer = m.getServer()
)
}
if (isPluginDisabled()) {
console.log('Omnisearch - Plugin disabled')
return
@@ -115,8 +121,8 @@ export default class OmnisearchPlugin extends Plugin {
this.executeFirstLaunchTasks()
await this.populateIndex()
if (settings.httpApiEnabled) {
if (this.apiHttpServer && settings.httpApiEnabled) {
this.apiHttpServer.listen(settings.httpApiPort)
}
})
@@ -267,4 +273,3 @@ function registerAPI(plugin: OmnisearchPlugin): void {
// Deprecated
;(app as any).plugins.plugins.omnisearch.api = api
}