mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 09:46:36 +00:00
Disconnect unused more-info (#945)
This commit is contained in:
parent
a88c6f49a2
commit
ebc21aaa40
@ -40,6 +40,16 @@ class MoreInfoCamera extends window.hassMixins.EventsMixin(Polymer.Element) {
|
||||
};
|
||||
}
|
||||
|
||||
connectedCallback() {
|
||||
super.connectedCallback();
|
||||
this.isVisible = true;
|
||||
}
|
||||
|
||||
disconnectedCallback() {
|
||||
this.isVisible = false;
|
||||
super.disconnectedCallback();
|
||||
}
|
||||
|
||||
imageLoaded() {
|
||||
this.fire('iron-resize');
|
||||
}
|
||||
|
@ -43,16 +43,21 @@ class MoreInfoContent extends Polymer.Element {
|
||||
|
||||
stateObjChanged(stateObj, hass) {
|
||||
if (!stateObj || !hass) {
|
||||
// If root has lastChild, set 'isVisible' attribute of that child to false.
|
||||
if (this.lastChild) {
|
||||
this.lastChild.isVisible = false;
|
||||
this._detachedChild = this.lastChild;
|
||||
// Detach child to prevent it from doing work.
|
||||
this.removeChild(this.lastChild);
|
||||
}
|
||||
} else {
|
||||
window.hassUtil.dynamicContentUpdater(
|
||||
this, 'MORE-INFO-' + window.hassUtil.stateMoreInfoType(stateObj).toUpperCase(),
|
||||
{ hass: hass, stateObj: stateObj, isVisible: true }
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (this._detachedChild) {
|
||||
this.appendChild(this._detachedChild);
|
||||
this._detachedChild = null;
|
||||
}
|
||||
window.hassUtil.dynamicContentUpdater(
|
||||
this, 'MORE-INFO-' + window.hassUtil.stateMoreInfoType(stateObj).toUpperCase(),
|
||||
{ hass: hass, stateObj: stateObj }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user