#302 - Fixed
This commit is contained in:
15
src/main.ts
15
src/main.ts
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user