ionic-team / pwa-elements

Quality UI experiences for Web APIs that require custom UI (such as media/camera).
https://medium.com/@maxlynch/building-the-progressive-web-app-os-57daebcb69c1
MIT License
168 stars 50 forks source link

Fixes GET request on undefined image #76

Closed pfeigl closed 2 years ago

pfeigl commented 3 years ago

The UI re-render's as soon as this.photo is set, as it's annotaed with @State.

The problem comes up when the UI renders faster as getOrientation and the following setting of this.photoSrc can execute (which happens reproducible for me).

With the UI already rendering and photoSrc not beeing set, the accept-image tries to request undefined.

To fix this, I moved setting this.photo to the end of promptAccept.

I did the following additional changes:

pfeigl commented 3 years ago

For reproducing the original problem: Just serve the stencil app and take a photo. For me it gives this every time: image

Background is, that here https://github.com/ionic-team/pwa-elements/blob/6e1394a00b891a0242fea1f41b151681f1012d2a/src/components/camera/camera.tsx#L436

photoSrc might not be set already, while photo is already set.

pfeigl commented 3 years ago

Is there anything we can do, to get this merged?

pfeigl commented 3 years ago

Help? ;-(

jcesarmobile commented 2 years ago

Thanks for the PR!

I've merged another one that also fixed the issue in a different way, so closing this one.

Stencil used to remove console logs in production, but not anymore. I will switch them to console.debug as they are still helpful while in development and stencil removes them when doing a production build