Skip to content

Commit

Permalink
Desktop: Fixes #6719: Avoid reloading loaded plugin scripts (#6742)
Browse files Browse the repository at this point in the history
  • Loading branch information
SeptemberHX authored Aug 21, 2022
1 parent b4ece67 commit 36871d9
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import uuid from '@joplin/lib/uuid';

import { reg } from '@joplin/lib/registry';

const loadedPluginIdSet = new Set<string>();

export default function useExternalPlugins(CodeMirror: any, plugins: PluginStates) {

const [options, setOptions] = useState({});
Expand All @@ -17,6 +19,10 @@ export default function useExternalPlugins(CodeMirror: any, plugins: PluginState

for (const contentScript of contentScripts) {
try {
if (loadedPluginIdSet.has(contentScript.id)) {
continue;
}

const mod = contentScript.module;

if (mod.codeMirrorResources) {
Expand Down Expand Up @@ -64,6 +70,8 @@ export default function useExternalPlugins(CodeMirror: any, plugins: PluginState
if (mod.plugin) {
mod.plugin(CodeMirror);
}

loadedPluginIdSet.add(contentScript.id);
} catch (error) {
reg.logger().error(error.toString());
}
Expand Down

0 comments on commit 36871d9

Please sign in to comment.