Skip to content

Commit

Permalink
Merge pull request #100 from Genymobile/fix/change-check-for-not-load…
Browse files Browse the repository at this point in the history
…-plugin-dependency-twice

replace way of check if plugin charged
  • Loading branch information
jparez authored Sep 10, 2024
2 parents 8ba90f0 + e7774b8 commit a799c63
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/DeviceRendererFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ module.exports = class DeviceRendererFactory {

this.instances.push(instance);

this.addPlugins(instance);
this.loadPlugins(instance);
instance.onWebRTCReady();

return instance.apiManager.getExposedApiFunctions();
Expand Down Expand Up @@ -195,7 +195,7 @@ module.exports = class DeviceRendererFactory {
* @param {DeviceRenderer} instance The DeviceRenderer instance reference to link into each plugin.
* @param {Object} options Various configuration options.
*/
addPlugins(instance) {
loadPlugins(instance) {
/*
* Load instance dedicated plugins
*/
Expand All @@ -209,19 +209,20 @@ module.exports = class DeviceRendererFactory {
}
}

const dependenciesLoaded = [];
const dependenciesLoaded = new Map();
pluginInitMap.forEach((plugin) => {
const args = plugin.params || [];

if (plugin.enabled) {
// load dependencies
if (plugin.dependencies) {
plugin.dependencies.forEach((Dep) => {
if (dependenciesLoaded.indexOf(Dep.name) !== -1) {
if (dependenciesLoaded.has(Dep)) {
return;
}

new Dep(instance);
dependenciesLoaded.push(Dep.name);
dependenciesLoaded.set(Dep, true);
});
}
// eslint-disable-next-line no-unused-expressions
Expand Down

0 comments on commit a799c63

Please sign in to comment.