diff --git a/src/settings.ts b/src/settings.ts index 04dda3f..7abf9a5 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -61,6 +61,7 @@ export interface OmnisearchSettings extends WeightingSettings { fuzziness: '0' | '1' | '2' httpApiEnabled: boolean httpApiPort: string + httpApiNotice: boolean } /** @@ -504,6 +505,18 @@ export class SettingsTab extends PluginSettingTab { await saveSettings(this.plugin) }) }) + + new Setting(containerEl) + .setName('Show a notification when the server starts') + .setDesc( + 'Will display a notification if the server is enabled, at Obsidian startup.' + ) + .addToggle(toggle => + toggle.setValue(settings.httpApiNotice).onChange(async v => { + settings.httpApiNotice = v + await saveSettings(this.plugin) + }) + ) } //#endregion HTTP Server @@ -613,6 +626,7 @@ export const DEFAULT_SETTINGS: OmnisearchSettings = { httpApiEnabled: false, httpApiPort: '51361', + httpApiNotice: true, welcomeMessage: '', verboseLogging: false, diff --git a/src/tools/api-server.ts b/src/tools/api-server.ts index b4708b6..05bce47 100644 --- a/src/tools/api-server.ts +++ b/src/tools/api-server.ts @@ -47,7 +47,9 @@ export function getServer() { }, () => { console.log(`Omnisearch - Started HTTP server on port ${port}`) - new Notice(`Omnisearch - Started HTTP server on port ${port}`) + if (settings.httpApiNotice) { + new Notice(`Omnisearch - Started HTTP server on port ${port}`) + } } ) @@ -61,7 +63,9 @@ export function getServer() { close() { server.close() console.log(`Omnisearch - Terminated HTTP server`) - new Notice(`Omnisearch - Terminated HTTP server`) + if (settings.httpApiNotice) { + new Notice(`Omnisearch - Terminated HTTP server`) + } }, } }