From 15ece9740859ce3cd6c4750e70f5411a357e3487 Mon Sep 17 00:00:00 2001 From: Dermot Duffy Date: Thu, 23 Jun 2022 21:09:28 -0700 Subject: [PATCH] Show reconnection on startup. --- src/card.ts | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/src/card.ts b/src/card.ts index 32322436..8f57cd9d 100644 --- a/src/card.ts +++ b/src/card.ts @@ -1104,27 +1104,31 @@ export class FrigateCard extends LitElement { const oldHass = changedProps.get('_hass') as HomeAssistant | undefined; let shouldUpdate = !oldHass || changedProps.size != 1; + // If this is the first HA state and it is disconnected, or there's been a + // change in connection state, then show the reconnection message. + if ( + (!oldHass && !this._hass?.connected) || + (!!oldHass && oldHass.connected !== !!this._hass?.connected) + ) { + if (!this._hass?.connected) { + this._setMessageAndUpdate( + { + message: localize('error.reconnecting'), + icon: 'mdi:lan-disconnect', + type: 'info', + dotdotdot: true, + }, + true, + ); + } else { + this._changeView(); + } + return true; + } + if (oldHass) { const selectedCamera = this._getSelectedCameraConfig(); - if (oldHass.connected !== !!this._hass?.connected) { - if (!this._hass?.connected) { - this._setMessageAndUpdate( - { - message: localize('error.reconnecting'), - icon: 'mdi:lan-disconnect', - type: 'info', - dotdotdot: true, - }, - true, - ); - } else { - this._changeView(); - } - shouldUpdate = true; - } else if ( - this._getConfig().view.scan.enabled && - this._updateTriggeredCameras(oldHass) - ) { + if (this._getConfig().view.scan.enabled && this._updateTriggeredCameras(oldHass)) { shouldUpdate = true; } else if ( // Home Assistant pumps a lot of updates through. Re-rendering the card is