Skip to content

Commit

Permalink
geosolutions-it#10867: Fix - Saving context loads duplicate extension…
Browse files Browse the repository at this point in the history
…s as scripts
  • Loading branch information
dsuren1 committed Feb 26, 2025
1 parent aed4dae commit 30790a0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion web/client/components/app/withExtensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ function withExtensions(AppComponent) {
pluginsRegistry: plugins
});
if (translations.length > 0) {
ConfigUtils.setConfigProp("translationsPath", [...castArray(ConfigUtils.getConfigProp("translationsPath")), ...translations.map(this.getAssetPath)]);
// remove any duplicate paths
const translationsPath = [...new Set([...castArray(ConfigUtils.getConfigProp("translationsPath")), ...translations.map(this.getAssetPath)])];
ConfigUtils.setConfigProp("translationsPath", translationsPath);
}
const locale = ConfigUtils.getConfigProp('locale');
store.dispatch(loadLocale(null, locale));
Expand Down
12 changes: 8 additions & 4 deletions web/client/utils/PluginsUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -626,10 +626,14 @@ export const createPlugin = (name, { component, options = {}, containers = {}, r
* @returns {Promise} a Promise that resolves to a lazy plugin object.
*/
export const loadPlugin = (pluginUrl, pluginName) => {
return loadScript(pluginUrl)
.then(() =>importPlugin(pluginName))
.then((plugin) => ({ name: pluginName, plugin}));

return new Promise((resolve, reject) => {
const script = document.querySelector(`script[src="${pluginUrl}"]`);
// load the script if not already loaded
const load = script ? Promise.resolve() : loadScript(pluginUrl);
load.then(() => importPlugin(pluginName))
.then(plugin => resolve({ name: pluginName, plugin }))
.catch(reject);
});
};

/**
Expand Down

0 comments on commit 30790a0

Please sign in to comment.