feat(electron): support object-based electronSwitches#4161
feat(electron): support object-based electronSwitches#4161KristjanESPERANTO wants to merge 2 commits into
Conversation
Adds js/electron_helper.js with applyElectronSwitches(), which handles both string and object entries in the electronSwitches config array and logs each activated switch. The hardcoded autoplay-policy default switch is moved into the helper so all switch logic lives in one place. Fixes MagicMirrorOrg#4159
Electron's webPreferences.autoplayPolicy already defaults to "no-user-gesture-required", making the commandLine switch redundant.
|
Good catch! I hadn't questioned it since it was already there before my changes. So you're right - since |
sdetweil
left a comment
There was a problem hiding this comment.
In the for loop name/value is there a way to catch value as string or number not object, so String(value) doesn’t fail
|
Yes, we could add that check. I’m just not sure it’s a realistic case worth handling: valid values are normally strings or numbers, and passing an object/array would be a fairly unusual config mistake. It also wouldn’t crash - |
|
Ok. I’m alright with no check if you think it is non fatal this is a breaking change for my very old configs, I wonder who else it will impact.. |
|
Since this never really worked correctly from what I can tell, I don’t see a big risk of breaking many existing setups. I might be wrong, of course, but my suggestion is to merge this and see if anyone reports a real-world config. |

Previously,
electronSwitchesonly accepted strings. This PR adds support for object entries, allowing switches with values:I decided to put the logic into a helper file so it can be unit-tested independently, since electron.js itself requires a live Electron environment and cannot be tested in isolation.
Fixes #4159