-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix plugin loader for function definitions in window #2186
Conversation
But if it is a class, it'll still break because it's missing the arguments/it's calling new twice. We have to fix this differently then.. |
Something like this might work, did not test it: |
Yes, that could work. I'll try it later and if it does, I'll add it to this PR. |
Looks like it doesn't, since functions also have the constructor attribute. |
I just pushed a "fix", the code looks a bit Spaghetti, but should be working. Gotta do some additional testing though. |
Tested on production with the Android app, and it works just fine 🎉 |
I'm not a fan of the spaghetti this adds. Maybe we should just straight revert and not support classes directly? Is it bad if we just say for classes you must return them from a function? It would be nice if we had a well defined spec for these plugins and what is supported. |
As long as there's a documented spec, I'm happy with both options. We just need to decide and document it somewhere. |
jellyfin-android does use functions because classes didn't work when I implemented it so I guess we can remove it yes. |
4b7ccc4
to
6ac1921
Compare
I reverted my spagehtti-ish workaround, as we discussed internally to not support the classes directly in window. Instead, that should be documented and this PR could be merged now. However, I still want to use some changes from my earlier commit (4b7ccc4) to refactor the current code a bit and make it more readable. |
This reverts commit 2dede41.
f2b6260
to
a7fb8eb
Compare
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Fix plugin loader for function definitions in window (cherry picked from commit 3992265) Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
This reverts commit 2dede41 and fixes supporting functions as well as classes as plugin definitions in window.
The previous change breaks plugin loading on Android, as plugin definitions with a function return a Promise to the class (async function), which cannot be instantiated. The Promise needs to be awaited on first; and the instantiation requires the default dependencies as constructor arguments.