royto / logbook-card

Logbook card for Home Assistant UI Lovelace
GNU General Public License v3.0
204 stars 9 forks source link

Card not being handled correctly when removed from DOM #73

Closed Sian-Lee-SA closed 8 months ago

Sian-Lee-SA commented 1 year ago

This card is still calling api history after it has been removed. Seems you're not handling disconnected callbacks and stopping event listeners which is keeping the element alive.

royto commented 1 year ago

What do you mean by removed from the DOM ? Changing tabs ? removing the card ? Do you have an example when it occurs ?

there reload of the history is triggered when HA frontend call the shouldUpdate method (there is no api call if HA do not call this method ...

Sian-Lee-SA commented 1 year ago

Could be a condition card or dialog... I noticed the action handlers don't have disconnected callbacks.

EDIT: I haven't reviewed the code thoroughly but that's probably where it's happening. This in retrospect would keep the element alive.

Also the terminlogy of removing from the DOM means it no longer exists in the document

Sian-Lee-SA commented 1 year ago

Network tab on browser shows the calls continue even when navigating away to any page. The only way to stop is refreshing the browser

royto commented 1 year ago

I don't reproduce the issue when changing tab or page ...

royto commented 12 months ago

Version 2.1.1 should resolve the issue. Data refreshing is now based on lit element lifecycle events 'connectedCallback' and 'disconnectedCallback'