#310 - Server notice display is now opt-out

This commit is contained in:
Simon Cambier
2023-11-01 14:02:45 +01:00
parent 8355489bcd
commit 8832ce7b78
2 changed files with 20 additions and 2 deletions

View File

@@ -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,

View File

@@ -47,8 +47,10 @@ export function getServer() {
},
() => {
console.log(`Omnisearch - Started HTTP server on port ${port}`)
if (settings.httpApiNotice) {
new Notice(`Omnisearch - Started HTTP server on port ${port}`)
}
}
)
server.on('error', e => {
@@ -61,7 +63,9 @@ export function getServer() {
close() {
server.close()
console.log(`Omnisearch - Terminated HTTP server`)
if (settings.httpApiNotice) {
new Notice(`Omnisearch - Terminated HTTP server`)
}
},
}
}