mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-20 15:56:35 +00:00
Update of core or OS will disconnect (#17170)
This commit is contained in:
parent
1b0423eb42
commit
507f22a5cd
@ -10,5 +10,15 @@ export const callExecuteScript = (
|
|||||||
sequence,
|
sequence,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const serviceCallWillDisconnect = (domain: string, service: string) =>
|
export const serviceCallWillDisconnect = (
|
||||||
domain === "homeassistant" && ["restart", "stop"].includes(service);
|
domain: string,
|
||||||
|
service: string,
|
||||||
|
serviceData?: Record<string, any>
|
||||||
|
) =>
|
||||||
|
(domain === "homeassistant" && ["restart", "stop"].includes(service)) ||
|
||||||
|
(domain === "update" &&
|
||||||
|
service === "install" &&
|
||||||
|
[
|
||||||
|
"update.home_assistant_core_update",
|
||||||
|
"update.home_assistant_operating_system_update",
|
||||||
|
].includes(serviceData?.entity_id));
|
||||||
|
@ -100,7 +100,7 @@ export const connectionMixin = <T extends Constructor<HassBaseEl>>(
|
|||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
if (
|
if (
|
||||||
err.error?.code === ERR_CONNECTION_LOST &&
|
err.error?.code === ERR_CONNECTION_LOST &&
|
||||||
serviceCallWillDisconnect(domain, service)
|
serviceCallWillDisconnect(domain, service, serviceData)
|
||||||
) {
|
) {
|
||||||
return { context: { id: "" } };
|
return { context: { id: "" } };
|
||||||
}
|
}
|
||||||
@ -121,7 +121,12 @@ export const connectionMixin = <T extends Constructor<HassBaseEl>>(
|
|||||||
"ui.notification_toast.service_call_failed",
|
"ui.notification_toast.service_call_failed",
|
||||||
"service",
|
"service",
|
||||||
`${domain}/${service}`
|
`${domain}/${service}`
|
||||||
) + ` ${err.message}`;
|
) +
|
||||||
|
` ${
|
||||||
|
err.message || err.error?.code === ERR_CONNECTION_LOST
|
||||||
|
? "connection lost"
|
||||||
|
: "unknown error"
|
||||||
|
}`;
|
||||||
fireEvent(this as any, "hass-notification", { message });
|
fireEvent(this as any, "hass-notification", { message });
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user