diff --git a/client/src/modules/core/pluginmanager.js b/client/src/modules/core/pluginmanager.js index fff10a3f..6c719995 100644 --- a/client/src/modules/core/pluginmanager.js +++ b/client/src/modules/core/pluginmanager.js @@ -62,7 +62,6 @@ class PluginManager extends Module { } async loadAllPlugins() { - console.log("LOAD ALL PLUGINS!"); try { const directories = await FileUtils.readDir(this.pluginsPath); @@ -81,6 +80,32 @@ class PluginManager extends Module { } } + async refreshPlugins() { + if (this.plugins.length <= 0) return this.loadAllPlugins(); + try { + const directories = await FileUtils.readDir(this.pluginsPath); + for (let dir of directories) { + //If a plugin is already loaded this should resolve. + if (this.getPluginByDirName(dir)) continue; + + try { + //Load the plugin if not + await this.loadPlugin(dir); + } catch (err) { + //We don't want every plugin to fail loading when one does + Logger.err('PluginManager', err); + } + } + + for (let plugin of this.plugins) { + if (directories.includes(plugin.dirName)) continue; + //Plugin was deleted manually, stop it and remove any reference + } + } catch (err) { + throw err; + } + } + async loadPlugin(pluginPath) { const { plugins } = this.state; const dirName = pluginPath; diff --git a/client/src/modules/ui/vue/components/bd/PluginsView.vue b/client/src/modules/ui/vue/components/bd/PluginsView.vue index d251cd75..79785285 100644 --- a/client/src/modules/ui/vue/components/bd/PluginsView.vue +++ b/client/src/modules/ui/vue/components/bd/PluginsView.vue @@ -12,7 +12,7 @@ /*Methods*/ async function refreshLocalPlugins() { try { - await PluginManager.loadAllPlugins(); + await PluginManager.refreshPlugins(); } catch (err) { }