#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' fuzziness: '0' | '1' | '2'
httpApiEnabled: boolean httpApiEnabled: boolean
httpApiPort: string httpApiPort: string
httpApiNotice: boolean
} }
/** /**
@@ -504,6 +505,18 @@ export class SettingsTab extends PluginSettingTab {
await saveSettings(this.plugin) 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 //#endregion HTTP Server
@@ -613,6 +626,7 @@ export const DEFAULT_SETTINGS: OmnisearchSettings = {
httpApiEnabled: false, httpApiEnabled: false,
httpApiPort: '51361', httpApiPort: '51361',
httpApiNotice: true,
welcomeMessage: '', welcomeMessage: '',
verboseLogging: false, verboseLogging: false,

View File

@@ -47,7 +47,9 @@ export function getServer() {
}, },
() => { () => {
console.log(`Omnisearch - Started HTTP server on port ${port}`) 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() { close() {
server.close() server.close()
console.log(`Omnisearch - Terminated HTTP server`) console.log(`Omnisearch - Terminated HTTP server`)
new Notice(`Omnisearch - Terminated HTTP server`) if (settings.httpApiNotice) {
new Notice(`Omnisearch - Terminated HTTP server`)
}
}, },
} }
} }