mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Delay showing connection message (#17595)
This commit is contained in:
parent
12b61aea2f
commit
613cf932b5
@ -17,6 +17,8 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
|
|||||||
class extends superClass {
|
class extends superClass {
|
||||||
private _subscribedBootstrapIntegrations?: Promise<UnsubscribeFunc>;
|
private _subscribedBootstrapIntegrations?: Promise<UnsubscribeFunc>;
|
||||||
|
|
||||||
|
private _disconnectedTimeout?: number;
|
||||||
|
|
||||||
protected firstUpdated(changedProps) {
|
protected firstUpdated(changedProps) {
|
||||||
super.firstUpdated(changedProps);
|
super.firstUpdated(changedProps);
|
||||||
// Need to load in advance because when disconnected, can't dynamically load code.
|
// Need to load in advance because when disconnected, can't dynamically load code.
|
||||||
@ -65,6 +67,11 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
|
|||||||
|
|
||||||
protected hassReconnected() {
|
protected hassReconnected() {
|
||||||
super.hassReconnected();
|
super.hassReconnected();
|
||||||
|
if (this._disconnectedTimeout) {
|
||||||
|
clearTimeout(this._disconnectedTimeout);
|
||||||
|
this._disconnectedTimeout = undefined;
|
||||||
|
return;
|
||||||
|
}
|
||||||
showToast(this, {
|
showToast(this, {
|
||||||
message: "",
|
message: "",
|
||||||
duration: 1,
|
duration: 1,
|
||||||
@ -74,11 +81,14 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
|
|||||||
protected hassDisconnected() {
|
protected hassDisconnected() {
|
||||||
super.hassDisconnected();
|
super.hassDisconnected();
|
||||||
|
|
||||||
showToast(this, {
|
this._disconnectedTimeout = window.setTimeout(() => {
|
||||||
message: this.hass!.localize("ui.notification_toast.connection_lost"),
|
this._disconnectedTimeout = undefined;
|
||||||
duration: 0,
|
showToast(this, {
|
||||||
dismissable: false,
|
message: this.hass!.localize("ui.notification_toast.connection_lost"),
|
||||||
});
|
duration: 0,
|
||||||
|
dismissable: false,
|
||||||
|
});
|
||||||
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _handleMessage(message: BootstrapIntegrationsTimings): void {
|
private _handleMessage(message: BootstrapIntegrationsTimings): void {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user