From 376e4ebde09ad0b548ebc1fedddaced461b0a518 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Mon, 3 Apr 2023 18:01:06 +0200 Subject: [PATCH 1/4] Desktop: Fixed display of installed plugins in About box --- packages/app-desktop/gui/MenuBar.tsx | 7 +++++-- packages/lib/services/plugins/PluginService.ts | 5 +++++ packages/lib/versionInfo.test.ts | 18 ------------------ packages/lib/versionInfo.ts | 12 ++++-------- 4 files changed, 14 insertions(+), 28 deletions(-) diff --git a/packages/app-desktop/gui/MenuBar.tsx b/packages/app-desktop/gui/MenuBar.tsx index 22cf6dbabf..79589d4f4b 100644 --- a/packages/app-desktop/gui/MenuBar.tsx +++ b/packages/app-desktop/gui/MenuBar.tsx @@ -21,7 +21,7 @@ import checkForUpdates from '../checkForUpdates'; const { connect } = require('react-redux'); import { reg } from '@joplin/lib/registry'; import { ProfileConfig } from '@joplin/lib/services/profileConfig/types'; -import PluginService from '@joplin/lib/services/plugins/PluginService'; +import PluginService, { PluginSettings } from '@joplin/lib/services/plugins/PluginService'; const packageInfo = require('../packageInfo.js'); const { clipboard } = require('electron'); const Menu = bridge().Menu; @@ -128,6 +128,7 @@ interface Props { customCss: string; locale: string; profileConfig: ProfileConfig; + pluginSettings: PluginSettings; } const commandNames: string[] = menuCommandNames(); @@ -487,7 +488,7 @@ function useMenu(props: Props) { } function _showAbout() { - const v = versionInfo(packageInfo, PluginService.instance().plugins); + const v = versionInfo(packageInfo, PluginService.instance().enabledPlugins(props.pluginSettings)); const copyToClipboard = bridge().showMessageBox(v.message, { icon: `${bridge().electronApp().buildDir()}/icons/128x128.png`, @@ -930,6 +931,7 @@ function useMenu(props: Props) { props['spellChecker.languages'], // eslint-disable-next-line @seiyab/react-hooks/exhaustive-deps -- Old code before rule was applied props['spellChecker.enabled'], + props.pluginSettings, props.customCss, props.locale, props.profileConfig, @@ -985,6 +987,7 @@ const mapStateToProps = (state: AppState) => { ['folders.sortOrder.field']: state.settings['folders.sortOrder.field'], ['notes.sortOrder.reverse']: state.settings['notes.sortOrder.reverse'], ['folders.sortOrder.reverse']: state.settings['folders.sortOrder.reverse'], + pluginSettings: state.settings['plugins.states'], showNoteCounts: state.settings.showNoteCounts, uncompletedTodosOnTop: state.settings.uncompletedTodosOnTop, showCompletedTodos: state.settings.showCompletedTodos, diff --git a/packages/lib/services/plugins/PluginService.ts b/packages/lib/services/plugins/PluginService.ts index f327b77eb3..40a10e54ee 100644 --- a/packages/lib/services/plugins/PluginService.ts +++ b/packages/lib/services/plugins/PluginService.ts @@ -100,6 +100,11 @@ export default class PluginService extends BaseService { return this.plugins_; } + public enabledPlugins(pluginSettings: PluginSettings): Plugins { + const enabledPlugins = Object.fromEntries(Object.entries(this.plugins_).filter((p) => this.pluginEnabled(pluginSettings, p[0]))); + return enabledPlugins; + } + public get pluginIds(): string[] { return Object.keys(this.plugins_); } diff --git a/packages/lib/versionInfo.test.ts b/packages/lib/versionInfo.test.ts index 5faa204d7c..6ba1f2aa55 100644 --- a/packages/lib/versionInfo.test.ts +++ b/packages/lib/versionInfo.test.ts @@ -2,8 +2,6 @@ import versionInfo from './versionInfo'; import { reg } from './registry'; import { Plugins } from './services/plugins/PluginService'; import Plugin from './services/plugins/Plugin'; -import Setting from './models/Setting'; -import { PluginSettings } from './services/plugins/PluginService'; jest.mock('./registry'); @@ -66,10 +64,6 @@ describe('getPluginLists', () => { const plugins: Plugins = {}; plugins[plugin.manifest.id] = plugin; - const pluginSettings: PluginSettings = {}; - pluginSettings[plugin.id] = { enabled: true, deleted: false, hasBeenUpdated: false }; - Setting.setValue('plugins.states', pluginSettings); - const v = versionInfo(packageInfo, plugins); expect(v.body).toMatch(/\n\nPlugin1: 1/); expect(v.message).toMatch(/\n\nPlugin1: 1/); @@ -93,12 +87,6 @@ describe('getPluginLists', () => { plugins[plugin.manifest.id] = plugin; } - const pluginSettings: PluginSettings = {}; - for (const key of Object.keys(plugins)) { - pluginSettings[key] = { enabled: true, deleted: false, hasBeenUpdated: false }; - } - Setting.setValue('plugins.states', pluginSettings); - const v = versionInfo(packageInfo, plugins); expect(v.body).toMatch(/\n\nPlugin1: 1\nPlugin2: 1\nPlugin3: 1/); @@ -124,12 +112,6 @@ describe('getPluginLists', () => { plugins[plugin.manifest.id] = plugin; } - const pluginSettings: PluginSettings = {}; - for (const key of Object.keys(plugins)) { - pluginSettings[key] = { enabled: true, deleted: false, hasBeenUpdated: false }; - } - Setting.setValue('plugins.states', pluginSettings); - const v = versionInfo(packageInfo, plugins); const body = '\n'; diff --git a/packages/lib/versionInfo.ts b/packages/lib/versionInfo.ts index 7ee4b67f04..78d8b347d2 100644 --- a/packages/lib/versionInfo.ts +++ b/packages/lib/versionInfo.ts @@ -2,7 +2,6 @@ import { _ } from './locale'; import Setting from './models/Setting'; import { reg } from './registry'; import { Plugins } from './services/plugins/PluginService'; -import PluginService from './services/plugins/PluginService'; interface PluginList { completeList: string; @@ -11,16 +10,13 @@ interface PluginList { function getPluginLists(plugins: Plugins): PluginList { const pluginList = []; - const pluginSettings = PluginService.instance().unserializePluginSettings(Setting.value('plugins.states')); - const enabledPlugins = Object.fromEntries(Object.entries(plugins).filter((p) => pluginSettings[p[0]] && pluginSettings[p[0]].enabled === true)); - - if (Object.keys(enabledPlugins).length > 0) { - for (const pluginId in enabledPlugins) { - pluginList.push(`${enabledPlugins[pluginId].manifest.name}: ${enabledPlugins[pluginId].manifest.version}`); + if (Object.keys(plugins).length > 0) { + for (const pluginId in plugins) { + pluginList.push(`${plugins[pluginId].manifest.name}: ${plugins[pluginId].manifest.version}`); } } - pluginList.sort(); + pluginList.sort(Intl.Collator().compare); let completeList = ''; let summary = ''; From b76586c4fda8dd9ea022cd7b18a5051f29cabe1f Mon Sep 17 00:00:00 2001 From: Self Not Found Date: Sun, 12 Mar 2023 23:21:31 +0800 Subject: [PATCH 2/4] All: Fixes #7851: Encode the non-ASCII characters in OneDrive URI (#7868) --- packages/lib/SyncTargetOneDrive.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/lib/SyncTargetOneDrive.ts b/packages/lib/SyncTargetOneDrive.ts index fa4e22bbc3..295718677f 100644 --- a/packages/lib/SyncTargetOneDrive.ts +++ b/packages/lib/SyncTargetOneDrive.ts @@ -103,7 +103,11 @@ export default class SyncTargetOneDrive extends BaseSyncTarget { } this.api_.setAccountProperties(accountProperties); const appDir = await this.api().appDirectory(); - const fileApi = new FileApi(appDir, new FileApiDriverOneDrive(this.api())); + // the appDir might contain non-ASCII characters + // /[^\u0021-\u00ff]/ is used in Node.js to detect the unescaped characters. + // See https://github.com/nodejs/node/blob/bbbf97b6dae63697371082475dc8651a6a220336/lib/_http_client.js#L176 + const baseDir = RegExp(/[^\u0021-\u00ff]/).exec(appDir) !== null ? encodeURI(appDir) : appDir; + const fileApi = new FileApi(baseDir, new FileApiDriverOneDrive(this.api())); fileApi.setSyncTargetId(this.syncTargetId()); fileApi.setLogger(this.logger()); return fileApi; From af0136ef39f3a5f76f92ea2c515ffc4dfa69a284 Mon Sep 17 00:00:00 2001 From: Henry Heino <46334387+personalizedrefrigerator@users.noreply.github.com> Date: Thu, 30 Mar 2023 09:41:29 -0700 Subject: [PATCH 3/4] All: Fixes #7986: Fix OneDrive sync attempting to call method on `null` variable (#7987) --- packages/lib/SyncTargetOneDrive.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/lib/SyncTargetOneDrive.ts b/packages/lib/SyncTargetOneDrive.ts index 295718677f..93f1060419 100644 --- a/packages/lib/SyncTargetOneDrive.ts +++ b/packages/lib/SyncTargetOneDrive.ts @@ -96,12 +96,14 @@ export default class SyncTargetOneDrive extends BaseSyncTarget { let context = Setting.value(`sync.${this.syncTargetId()}.context`); context = context === '' ? null : JSON.parse(context); let accountProperties = context ? context.accountProperties : null; + const api = this.api(); + if (!accountProperties) { - accountProperties = await this.api_.execAccountPropertiesRequest(); + accountProperties = await api.execAccountPropertiesRequest(); context ? context.accountProperties = accountProperties : context = { accountProperties: accountProperties }; Setting.setValue(`sync.${this.syncTargetId()}.context`, JSON.stringify(context)); } - this.api_.setAccountProperties(accountProperties); + api.setAccountProperties(accountProperties); const appDir = await this.api().appDirectory(); // the appDir might contain non-ASCII characters // /[^\u0021-\u00ff]/ is used in Node.js to detect the unescaped characters. From 9645414c171b99eff4e07f1a897eff04742cf631 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Mon, 3 Apr 2023 18:10:54 +0200 Subject: [PATCH 4/4] Desktop release v2.10.13 --- packages/app-desktop/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/app-desktop/package.json b/packages/app-desktop/package.json index 86b00dc6d0..f4fcb093cd 100644 --- a/packages/app-desktop/package.json +++ b/packages/app-desktop/package.json @@ -1,6 +1,6 @@ { "name": "@joplin/app-desktop", - "version": "2.10.12", + "version": "2.10.13", "description": "Joplin for Desktop", "main": "main.js", "private": true,