From ceb7a7303d766d2ca047e168bf7b33c0dcee7cb3 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Tue, 13 Oct 2020 09:59:53 +0100 Subject: [PATCH] Desktop: Plugin API - added support for settings.globalValue method --- .eslintignore | 1 + .gitignore | 1 + .../tests/services/plugins/api/JoplinSetting.ts | 16 ++++++++++++++++ CliClient/tests/support/jasmine.json | 1 + .../lib/services/plugins/api/JoplinSettings.ts | 11 +++++++++++ 5 files changed, 30 insertions(+) create mode 100644 CliClient/tests/services/plugins/api/JoplinSetting.ts diff --git a/.eslintignore b/.eslintignore index cd371abc4..2244f393a 100644 --- a/.eslintignore +++ b/.eslintignore @@ -69,6 +69,7 @@ CliClient/tests/services_CommandService.js CliClient/tests/services_InteropService.js CliClient/tests/services_PluginService.js CliClient/tests/services_rest_Api.js +CliClient/tests/services/plugins/api/JoplinSetting.js CliClient/tests/services/plugins/sandboxProxy.js CliClient/tests/synchronizer_LockHandler.js CliClient/tests/synchronizer_MigrationHandler.js diff --git a/.gitignore b/.gitignore index a43e007a3..97b355719 100644 --- a/.gitignore +++ b/.gitignore @@ -63,6 +63,7 @@ CliClient/tests/services_CommandService.js CliClient/tests/services_InteropService.js CliClient/tests/services_PluginService.js CliClient/tests/services_rest_Api.js +CliClient/tests/services/plugins/api/JoplinSetting.js CliClient/tests/services/plugins/sandboxProxy.js CliClient/tests/synchronizer_LockHandler.js CliClient/tests/synchronizer_MigrationHandler.js diff --git a/CliClient/tests/services/plugins/api/JoplinSetting.ts b/CliClient/tests/services/plugins/api/JoplinSetting.ts new file mode 100644 index 000000000..8951c50c2 --- /dev/null +++ b/CliClient/tests/services/plugins/api/JoplinSetting.ts @@ -0,0 +1,16 @@ +// import Setting from 'lib/models/Setting'; + +// const { asyncTest, setupDatabaseAndSynchronizer, switchClient, expectThrow, expectNotThrow } = require('../test-utils.js'); + +// describe('plugin_api_JoplinSetting', function() { + +// beforeEach(async (done) => { +// await setupDatabaseAndSynchronizer(1); +// await switchClient(1); +// done(); +// }); + +// it('should get and set plugin-specific values', asyncTest(async () => { +// await +// })); +// }); diff --git a/CliClient/tests/support/jasmine.json b/CliClient/tests/support/jasmine.json index b4af2c1a9..361bac445 100644 --- a/CliClient/tests/support/jasmine.json +++ b/CliClient/tests/support/jasmine.json @@ -3,6 +3,7 @@ "spec_files": [ "*.js", "services/plugins/*.js", + "services/plugins/api/*.js", "!test-utils.js" ], "stopSpecOnExpectationFailure": false, diff --git a/ReactNativeClient/lib/services/plugins/api/JoplinSettings.ts b/ReactNativeClient/lib/services/plugins/api/JoplinSettings.ts index 9981ed7e1..f72fd2177 100644 --- a/ReactNativeClient/lib/services/plugins/api/JoplinSettings.ts +++ b/ReactNativeClient/lib/services/plugins/api/JoplinSettings.ts @@ -73,4 +73,15 @@ export default class JoplinSettings { async setValue(key:string, value:any) { return Setting.setValue(this.namespacedKey(key), value); } + + /** + * Gets a global setting value, including app-specific settings and those set by other plugins. + * + * The list of available settings is not documented yet, but can be found by looking at the source code: + * + * https://github.com/laurent22/joplin/blob/3539a452a359162c461d2849829d2d42973eab50/ReactNativeClient/lib/models/Setting.ts#L142 + */ + async globalValue(key:string):Promise { + return Setting.value(key); + } }