Skip to content
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

Potential fix for not running on old iOS #414

Open
cburn opened this issue Nov 2, 2023 · 4 comments
Open

Potential fix for not running on old iOS #414

cburn opened this issue Nov 2, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@cburn
Copy link

cburn commented Nov 2, 2023

I have a potential fix for bug #150.

The card is failing to load on on old iOS devices as Safari/Webkit only supported the nullish coalescing operator '??' from iOS version 13.4.

I searched the installed www/community/power-flow-card-plus/power-flow-card-plus.js file for instances of "??" and there were 2 places where it appeared.

I edited super(a ?? l) to super(( a != null ) ? a : l) and o ?? (o = [e, ...t()]) to (o != null) ? o : (o = [e, ...t()]) in place and deleted the .gz version of the file, and it works perfectly on an old iPad mini running iOS 12.5.7

Sorry I don't know how to fix this in your code/release process but hopefully this points the right direction. Maybe some options to send through babel to target older browsers?

@cburn cburn added the bug Something isn't working label Nov 2, 2023
@flixlix
Copy link
Owner

flixlix commented Nov 8, 2023

Thanks for the hint, I'll check it out 👍

@Yorkie71
Copy link

This is great to see as I have HA running on an old iPad in the kitchen and it works fine but since Power Card Plus has been the primary card on the main dashboard, it's not worked on the iPad so hopefully this means that the old tech has a future again!

@flixlix
Copy link
Owner

flixlix commented Mar 26, 2024

Can you check if this fixes the issue, there are still two ?? in there, but maybe it's fixed now
power-flow-card-plus.js.zip

Edit: please make sure in the console shows the version 0.2.0-414 to make sure you are using the correct version

@steveworkman
Copy link

I've had a look deeper in the code at this (I'm pretty new to HA and am using an old iPad in the kitchen too!).

The issue comes from superstruct where this.failures is a function with a nullish operator inside. This is because the node modules aren't being transpiled with iOS 12 as a target, just to the current version of node.

So:
babel.config.js gets ["@babel/preset-env", { targets: { node: "current", ios: "12" } }]
and the rollup.config.js gets:

babel({
        exclude: /node_modules\/(?!superstruct)\/.*/,
        babelHelpers: "bundled",
      }),

I'll send over a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants