mirror of
https://github.com/laurent22/joplin.git
synced 2025-02-04 19:16:07 +02:00
Desktop: Disable built-in copy of Simple Backup by default in Joplin Portable (#9907)
This commit is contained in:
parent
627b830739
commit
39b44ff439
@ -172,6 +172,34 @@ describe('defaultPluginsUtils', () => {
|
|||||||
expect(Setting.value('plugin-io.github.jackgruber.backup.path')).toBe('initial-path');
|
expect(Setting.value('plugin-io.github.jackgruber.backup.path')).toBe('initial-path');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should support disabled-by-default plugins', async () => {
|
||||||
|
const service = newPluginService();
|
||||||
|
|
||||||
|
const plugin = await service.loadPluginFromJsBundle('', sampleJsBundlePlugin);
|
||||||
|
plugin.builtIn = false;
|
||||||
|
await service.runPlugin(plugin);
|
||||||
|
|
||||||
|
const defaultPluginsInfo: DefaultPluginsInfo = {
|
||||||
|
'joplin.plugin.ambrt.backlinksToNote': {
|
||||||
|
enabled: false,
|
||||||
|
},
|
||||||
|
'org.joplinapp.plugins.ToggleSidebars': {},
|
||||||
|
};
|
||||||
|
Setting.setValue('installedDefaultPlugins', []);
|
||||||
|
|
||||||
|
const { pluginSettings } = await getDefaultPluginPathsAndSettings(
|
||||||
|
testDefaultPluginsDir, defaultPluginsInfo, {}, service,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(pluginSettings).toMatchObject({
|
||||||
|
'joplin.plugin.ambrt.backlinksToNote': {
|
||||||
|
enabled: false,
|
||||||
|
deleted: false,
|
||||||
|
},
|
||||||
|
'org.joplinapp.plugins.ToggleSidebars': defaultPluginSetting(),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should not throw error on missing setting key', async () => {
|
it('should not throw error on missing setting key', async () => {
|
||||||
|
|
||||||
const service = newPluginService();
|
const service = newPluginService();
|
||||||
|
@ -34,6 +34,7 @@ export interface SettingAndValue {
|
|||||||
|
|
||||||
export interface DefaultPluginSettings {
|
export interface DefaultPluginSettings {
|
||||||
settings?: SettingAndValue;
|
settings?: SettingAndValue;
|
||||||
|
enabled?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DefaultPluginsInfo {
|
export interface DefaultPluginsInfo {
|
||||||
|
@ -65,6 +65,11 @@ export const getDefaultPluginPathsAndSettings = async (
|
|||||||
// As such, we recreate the plugin state if necessary.
|
// As such, we recreate the plugin state if necessary.
|
||||||
if (!draft[pluginId]) {
|
if (!draft[pluginId]) {
|
||||||
draft[pluginId] = defaultPluginSetting();
|
draft[pluginId] = defaultPluginSetting();
|
||||||
|
|
||||||
|
const enabledByDefault = defaultPluginsInfo[pluginId].enabled;
|
||||||
|
if (typeof enabledByDefault === 'boolean') {
|
||||||
|
draft[pluginId].enabled = enabledByDefault;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { DefaultPluginsInfo } from '../PluginService';
|
import { DefaultPluginsInfo } from '../PluginService';
|
||||||
import Setting from '../../../models/Setting';
|
import Setting from '../../../models/Setting';
|
||||||
|
import shim from '../../../shim';
|
||||||
|
|
||||||
const getDefaultPluginsInfo = (): DefaultPluginsInfo => {
|
const getDefaultPluginsInfo = (): DefaultPluginsInfo => {
|
||||||
const defaultPlugins = {
|
const defaultPlugins = {
|
||||||
@ -7,6 +8,11 @@ const getDefaultPluginsInfo = (): DefaultPluginsInfo => {
|
|||||||
settings: {
|
settings: {
|
||||||
'path': `${Setting.value('profileDir')}`,
|
'path': `${Setting.value('profileDir')}`,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Joplin Portable is more likely to run on a device with low write speeds
|
||||||
|
// and memory. Because Simple Backup has auto-backup enabled by default,
|
||||||
|
// we disable it in Joplin Portable.
|
||||||
|
enabled: !shim.isPortable(),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
return defaultPlugins;
|
return defaultPlugins;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user