From 715abcce32ec657b5ec9fba70d44802ca8d617c0 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Sun, 29 Sep 2024 17:44:08 +0100 Subject: [PATCH] Plugins: Add support for joplin.settings.values and deprecate joplin.settings.value --- .../lib/services/plugins/api/JoplinSettings.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/lib/services/plugins/api/JoplinSettings.ts b/packages/lib/services/plugins/api/JoplinSettings.ts index 8b79f5eea..1624141d3 100644 --- a/packages/lib/services/plugins/api/JoplinSettings.ts +++ b/packages/lib/services/plugins/api/JoplinSettings.ts @@ -147,6 +147,20 @@ export default class JoplinSettings { } /** + * Gets setting values (only applies to setting you registered from your plugin) + */ + public async values(keys: string[] | string): Promise> { + if (typeof keys === 'string') keys = [keys]; + const output: Record = {}; + for (const key of keys) { + output[key] = Setting.value(getPluginNamespacedSettingKey(this.plugin_.id, key)); + } + return output; + } + + /** + * @deprecated Use joplin.settings.values() + * * Gets a setting value (only applies to setting you registered from your plugin) */ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied