Support async onSettingsChange
This commit is contained in:
parent
51b66ea7cb
commit
24a792404c
|
@ -189,7 +189,7 @@ export class PluginManager implements ServerHook {
|
|||
return undefined
|
||||
}
|
||||
|
||||
onSettingsChanged (name: string, settings: any) {
|
||||
async onSettingsChanged (name: string, settings: any) {
|
||||
const registered = this.getRegisteredPluginByShortName(name)
|
||||
if (!registered) {
|
||||
logger.error('Cannot find plugin %s to call on settings changed.', name)
|
||||
|
@ -197,7 +197,7 @@ export class PluginManager implements ServerHook {
|
|||
|
||||
for (const cb of registered.registerHelpers.getOnSettingsChangedCallbacks()) {
|
||||
try {
|
||||
cb(settings)
|
||||
await cb(settings)
|
||||
} catch (err) {
|
||||
logger.error('Cannot run on settings changed callback for %s.', registered.npmName, { err })
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ export class RegisterHelpers {
|
|||
private idAndPassAuths: RegisterServerAuthPassOptions[] = []
|
||||
private externalAuths: RegisterServerAuthExternalOptions[] = []
|
||||
|
||||
private readonly onSettingsChangeCallbacks: ((settings: any) => void)[] = []
|
||||
private readonly onSettingsChangeCallbacks: ((settings: any) => Promise<any>)[] = []
|
||||
|
||||
private readonly router: express.Router
|
||||
|
||||
|
@ -277,7 +277,7 @@ export class RegisterHelpers {
|
|||
|
||||
setSetting: (name: string, value: string) => PluginModel.setSetting(this.plugin.name, this.plugin.type, name, value),
|
||||
|
||||
onSettingsChange: (cb: (settings: any) => void) => this.onSettingsChangeCallbacks.push(cb)
|
||||
onSettingsChange: (cb: (settings: any) => Promise<any>) => this.onSettingsChangeCallbacks.push(cb)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,5 +5,5 @@ export interface PluginSettingsManager {
|
|||
|
||||
setSetting: (name: string, value: string) => Promise<any>
|
||||
|
||||
onSettingsChange: (cb: (names: string[]) => void) => void
|
||||
onSettingsChange: (cb: (names: string[]) => Promise<any>) => void
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue