From d2d4a5a999746ae0f01a2ce89b844252346bab27 Mon Sep 17 00:00:00 2001 From: lutangar Date: Thu, 20 Jan 2022 12:07:15 +0100 Subject: Fix plugin settings manager definition This mainly fix the `onSettingsChange` argument typing. I'm not 100% sure the setting `value` can be a boolean though. But this is how it was typed before so I just made it consistent. Feel free to change - or suggest change - to the type names / location. --- .../server/managers/plugin-settings-manager.model.ts | 16 ++++++++++++---- .../plugins/server/settings/public-server.setting.ts | 4 +++- 2 files changed, 15 insertions(+), 5 deletions(-) (limited to 'shared/models') diff --git a/shared/models/plugins/server/managers/plugin-settings-manager.model.ts b/shared/models/plugins/server/managers/plugin-settings-manager.model.ts index 3c28c0565..b628718dd 100644 --- a/shared/models/plugins/server/managers/plugin-settings-manager.model.ts +++ b/shared/models/plugins/server/managers/plugin-settings-manager.model.ts @@ -1,9 +1,17 @@ +export type SettingValue = string | boolean + +export interface SettingEntries { + [settingName: string]: SettingValue +} + +export type SettingsChangeCallback = (settings: SettingEntries) => Promise + export interface PluginSettingsManager { - getSetting: (name: string) => Promise + getSetting: (name: string) => Promise - getSettings: (names: string[]) => Promise<{ [settingName: string]: string | boolean }> + getSettings: (names: string[]) => Promise - setSetting: (name: string, value: string) => Promise + setSetting: (name: string, value: SettingValue) => Promise - onSettingsChange: (cb: (names: string[]) => Promise) => void + onSettingsChange: (cb: SettingsChangeCallback) => void } diff --git a/shared/models/plugins/server/settings/public-server.setting.ts b/shared/models/plugins/server/settings/public-server.setting.ts index 9802c4d7d..d38e5424a 100644 --- a/shared/models/plugins/server/settings/public-server.setting.ts +++ b/shared/models/plugins/server/settings/public-server.setting.ts @@ -1,3 +1,5 @@ +import { SettingEntries } from '../managers/plugin-settings-manager.model' + export interface PublicServerSetting { - publicSettings: { [ name: string ]: string } + publicSettings: SettingEntries } -- cgit v1.2.3