1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-24 23:26:50 +02:00

Desktop: Resolves #4727: Add support for safe mode, which temporarily disables note rendering and plugins

This commit is contained in:
Laurent Cozic
2021-04-24 20:23:33 +02:00
parent 920f54f5d3
commit 3235f58f5a
13 changed files with 111 additions and 15 deletions

View File

@ -74,6 +74,7 @@ export default class PluginService extends BaseService {
private plugins_: Plugins = {};
private runner_: BasePluginRunner = null;
private startedPlugins_: Record<string, boolean> = {};
private isSafeMode_: boolean = false;
public initialize(appVersion: string, platformImplementation: any, runner: BasePluginRunner, store: any) {
this.appVersion_ = appVersion;
@ -86,6 +87,14 @@ export default class PluginService extends BaseService {
return this.plugins_;
}
public get isSafeMode(): boolean {
return this.isSafeMode_;
}
public set isSafeMode(v: boolean) {
this.isSafeMode_ = v;
}
private setPluginAt(pluginId: string, plugin: Plugin) {
this.plugins_ = {
...this.plugins_,
@ -346,6 +355,8 @@ export default class PluginService extends BaseService {
}
public async runPlugin(plugin: Plugin) {
if (this.isSafeMode) throw new Error(`Plugin was not started due to safe mode: ${plugin.manifest.id}`);
if (!this.isCompatible(plugin.manifest.app_min_version)) {
throw new Error(`Plugin "${plugin.id}" was disabled because it requires Joplin version ${plugin.manifest.app_min_version} and current version is ${this.appVersion_}.`);
} else {