From 049af5b00ceed4240d84bc14bbab7b4635f23648 Mon Sep 17 00:00:00 2001 From: Christopher Altona Date: Thu, 30 Jun 2022 02:43:13 +0000 Subject: [PATCH] Optimize undefined checks and don't fetch history twice --- src/panels/history/ha-panel-history.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/panels/history/ha-panel-history.ts b/src/panels/history/ha-panel-history.ts index 0f36274ccc..ec915fbb00 100644 --- a/src/panels/history/ha-panel-history.ts +++ b/src/panels/history/ha-panel-history.ts @@ -99,7 +99,7 @@ class HaPanelHistory extends SubscribeMixin(LitElement) { return accumulator; }, {}); this._deviceIdToEntities = entities.reduce((accumulator, current) => { - if (current.device_id === undefined || current.device_id === null) { + if (!current.device_id) { return accumulator; } let found = accumulator[current.device_id]; @@ -111,7 +111,7 @@ class HaPanelHistory extends SubscribeMixin(LitElement) { return accumulator; }, {}); this._areaIdToEntities = entities.reduce((accumulator, current) => { - if (current.area_id === undefined || current.area_id === null) { + if (!current.area_id) { return accumulator; } let found = accumulator[current.area_id]; @@ -129,7 +129,7 @@ class HaPanelHistory extends SubscribeMixin(LitElement) { return accumulator; }, {}); this._areaIdToDevices = devices.reduce((accumulator, current) => { - if (current.area_id === undefined || current.area_id === null) { + if (!current.area_id) { return accumulator; } let found = accumulator[current.area_id]; @@ -201,7 +201,7 @@ class HaPanelHistory extends SubscribeMixin(LitElement) { > ` : this._targetPickerValue === undefined - ? html`