amaximus / garbage-collection-card

Custom Lovelace card for Garbage Collection custom component
MIT License
127 stars 24 forks source link

Fix for slow or no loading at start #115

Closed Suxsem closed 10 months ago

Suxsem commented 10 months ago

I always noticed that most of the time the card was initially empty and only after some time it was properly rendered. Sometimes the card wasn't rendering at all.

I spent some minutes on the code and found the issue:

https://github.com/amaximus/garbage-collection-card/blob/68971f98d6269d65b210d6171a288534f685a215/dist/garbage-collection-card.js#L273

was fired before

https://github.com/amaximus/garbage-collection-card/blob/68971f98d6269d65b210d6171a288534f685a215/dist/garbage-collection-card.js#L337

and thus the _updateContent method was not able to read this.source.

This PR fixes the issue by setting this.source on first load at soon as possible.

No more issues!