Massive refactoring to get rid of the deprecated global app instance

This commit is contained in:
Simon Cambier
2024-05-21 21:13:35 +02:00
parent 1d30a62383
commit dcfb77f551
18 changed files with 167 additions and 148 deletions

View File

@@ -2,7 +2,7 @@ import * as http from 'http'
import * as url from 'url'
import api from './api'
import { Notice } from 'obsidian'
import { settings } from 'src/settings'
import { getSettings } from 'src/settings'
export function getServer() {
const server = http.createServer(async function (req, res) {
@@ -47,7 +47,7 @@ export function getServer() {
},
() => {
console.log(`Omnisearch - Started HTTP server on port ${port}`)
if (settings.httpApiNotice) {
if (getSettings().httpApiNotice) {
new Notice(`Omnisearch - Started HTTP server on port ${port}`)
}
}
@@ -62,6 +62,7 @@ export function getServer() {
},
close() {
server.close()
const settings = getSettings()
console.log(`Omnisearch - Terminated HTTP server`)
if (settings.httpApiEnabled && settings.httpApiNotice) {
new Notice(`Omnisearch - Terminated HTTP server`)