Add custom switches for electron mainWindow#2643
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #2643 +/- ##
===========================================
+ Coverage 71.01% 71.04% +0.03%
===========================================
Files 16 16
Lines 828 829 +1
===========================================
+ Hits 588 589 +1
Misses 240 240
Continue to review full report at Codecov.
|
|
What's the difference between this and the already implemented |
|
@MichMich |
|
Ok. If you can fix the conflict so I can merge it. Also, please create a PR in the docs repo (and if possible reference the PR in this PR). Thanks! |
|
Thanks. I'll do it in a few hours. |
|
Cool! Thanks for your PR! |
I reviewed the CodeQL alerts for `js/electron.js`: - [#25](https://github.com/MagicMirrorOrg/MagicMirror/security/code-scanning/25) https://github.com/MagicMirrorOrg/MagicMirror/security/code-scanning/25 - [#22](https://github.com/MagicMirrorOrg/MagicMirror/security/code-scanning/22) https://github.com/MagicMirrorOrg/MagicMirror/security/code-scanning/22 Both point to real bugs. - [#25](https://github.com/MagicMirrorOrg/MagicMirror/security/code-scanning/25): The window size fallback was written as a comma expression (`(800, 600)`), so it did not produce the expected object structure `{ width, height }`. I am not surprised it went unnoticed because it sits in a fallback path. - [#22](https://github.com/MagicMirrorOrg/MagicMirror/security/code-scanning/22): `...new Set(electronSwitchesDefaults, config.electronSwitches)` silently ignored the second parameter. As a result, custom `electronSwitches` were never applied. I am wondering: this has been broken since PR #2643 introduced it, so I'm quite sure it could not have worked as intended in that form. Why didn't anyone (not even @eouia) notice that? 🤔 ## Changes - Fix for [#25](https://github.com/MagicMirrorOrg/MagicMirror/security/code-scanning/25): - Corrects the fallback from `(800, 600)` to a valid size object `{ width: 800, height: 600 }`. - Fix for [#22](https://github.com/MagicMirrorOrg/MagicMirror/security/code-scanning/22): - Sets the default switch explicitly as a correct key-value pair: - `app.commandLine.appendSwitch("autoplay-policy", "no-user-gesture-required")` - Applies custom `config.electronSwitches` individually afterward.
I need some custom electron switches for my purpose. (e.g., Desktop background playing)
This feature enables adding custom switches on Electron starts by a user.
You can add switches in
config.jslike;