Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

20231026.0 #18431

Merged
merged 12 commits into from
Oct 26, 2023
Merged
4 changes: 2 additions & 2 deletions build-scripts/gulp/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ gulp.task(
gulp.parallel("gen-icons-json", "build-translations", "build-locale-data"),
"copy-static-app",
env.useRollup() ? "rollup-prod-app" : "webpack-prod-app",
gulp.parallel("gen-pages-app-prod", "gen-service-worker-app-prod"),
// Don't compress running tests
...(env.isTestBuild() ? [] : ["compress-app"]),
gulp.parallel("gen-pages-app-prod", "gen-service-worker-app-prod")
...(env.isTestBuild() ? [] : ["compress-app"])
)
);
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "home-assistant-frontend"
version = "20231025.1"
version = "20231026.0"
license = {text = "Apache-2.0"}
description = "The Home Assistant frontend"
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion src/components/chart/state-history-charts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ export class StateHistoryCharts extends LitElement {
);
} else {
this._computedStartTime = new Date(
this.historyData.timeline.reduce(
(this.historyData?.timeline ?? []).reduce(
(minTime, stateInfo) =>
Math.min(
minTime,
Expand Down
3 changes: 2 additions & 1 deletion src/components/ha-slider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export class HaSlider extends MdSlider {
:host {
--md-sys-color-primary: var(--primary-color);
--md-sys-color-outline: var(--outline-color);

--md-slider-handle-width: 14px;
--md-slider-handle-height: 14px;
min-width: 100px;
min-inline-size: 100px;
width: 200px;
Expand Down
5 changes: 5 additions & 0 deletions src/components/ha-textfield.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ export class HaTextField extends TextFieldBase {
text-align: var(--text-field-text-align, start);
}

/* Edge, hide reveal password icon */
::-ms-reveal {
display: none;
}

/* Chrome, Safari, Edge, Opera */
:host([no-spinner]) input::-webkit-outer-spin-button,
:host([no-spinner]) input::-webkit-inner-spin-button {
Expand Down
5 changes: 0 additions & 5 deletions src/data/lovelace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,6 @@ export const getLegacyLovelaceCollection = (conn: Connection) =>
)
);

export interface WindowWithLovelaceProm extends Window {
llConfProm?: Promise<LovelaceConfig>;
llResProm?: Promise<LovelaceResource[]>;
}

export interface ActionHandlerOptions {
hasHold?: boolean;
hasDoubleClick?: boolean;
Expand Down
8 changes: 8 additions & 0 deletions src/data/preloads.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { LovelaceConfig, LovelaceResource } from "./lovelace";
import { RecorderInfo } from "./recorder";

export interface WindowWithPreloads extends Window {
llConfProm?: Promise<LovelaceConfig>;
llResProm?: Promise<LovelaceResource[]>;
recorderInfoProm?: Promise<RecorderInfo>;
}
5 changes: 3 additions & 2 deletions src/data/recorder.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Connection } from "home-assistant-js-websocket";
import { computeStateName } from "../common/entity/compute_state_name";
import { HaDurationData } from "../components/ha-duration-input";
import { HomeAssistant } from "../types";
Expand Down Expand Up @@ -115,8 +116,8 @@ export interface StatisticsValidationResults {
[statisticId: string]: StatisticsValidationResult[];
}

export const getRecorderInfo = (hass: HomeAssistant) =>
hass.callWS<RecorderInfo>({
export const getRecorderInfo = (conn: Connection) =>
conn.sendMessagePromise<RecorderInfo>({
type: "recorder/info",
});

Expand Down
6 changes: 3 additions & 3 deletions src/data/todo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const enum TodoItemStatus {
}

export interface TodoItem {
uid?: string;
uid: string;
summary: string;
status: TodoItemStatus;
}
Expand Down Expand Up @@ -95,11 +95,11 @@ export const moveItem = (
hass: HomeAssistant,
entity_id: string,
uid: string,
pos: number
previous_uid: string | undefined
): Promise<void> =>
hass.callWS({
type: "todo/item/move",
entity_id,
uid,
pos,
previous_uid,
});
18 changes: 9 additions & 9 deletions src/entrypoints/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,9 @@ import {
import { loadTokens, saveTokens } from "../common/auth/token_storage";
import { hassUrl } from "../data/auth";
import { isExternal } from "../data/external";
import { getRecorderInfo } from "../data/recorder";
import { subscribeFrontendUserData } from "../data/frontend";
import {
fetchConfig,
fetchResources,
WindowWithLovelaceProm,
} from "../data/lovelace";
import { fetchConfig, fetchResources } from "../data/lovelace";
import { subscribePanels } from "../data/ws-panels";
import { subscribeThemes } from "../data/ws-themes";
import { subscribeRepairsIssueRegistry } from "../data/repairs";
Expand All @@ -27,6 +24,7 @@ import type { ExternalAuth } from "../external_app/external_auth";
import "../resources/array.flat.polyfill";
import "../resources/safari-14-attachshadow-patch";
import { MAIN_WINDOW_NAME } from "../data/main_window";
import { WindowWithPreloads } from "../data/preloads";

window.name = MAIN_WINDOW_NAME;
(window as any).frontendVersion = __VERSION__;
Expand Down Expand Up @@ -124,12 +122,14 @@ window.hassConnection.then(({ conn }) => {
subscribeFrontendUserData(conn, "core", noop);
subscribeRepairsIssueRegistry(conn, noop);

const preloadWindow = window as WindowWithPreloads;
preloadWindow.recorderInfoProm = getRecorderInfo(conn);

if (location.pathname === "/" || location.pathname.startsWith("/lovelace/")) {
const llWindow = window as WindowWithLovelaceProm;
llWindow.llConfProm = fetchConfig(conn, null, false);
llWindow.llConfProm.catch(() => {
preloadWindow.llConfProm = fetchConfig(conn, null, false);
preloadWindow.llConfProm.catch(() => {
// Ignore it, it is handled by Lovelace panel.
});
llWindow.llResProm = fetchResources(conn);
preloadWindow.llResProm = fetchResources(conn);
}
});
13 changes: 11 additions & 2 deletions src/layouts/home-assistant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import { customElement, state } from "lit/decorators";
import { isNavigationClick } from "../common/dom/is-navigation-click";
import { navigate } from "../common/navigate";
import { getStorageDefaultPanelUrlPath } from "../data/panel";
import { getRecorderInfo } from "../data/recorder";
import { getRecorderInfo, RecorderInfo } from "../data/recorder";
import "../resources/custom-card-support";
import { HassElement } from "../state/hass-element";
import QuickBarMixin from "../state/quick-bar-mixin";
import { HomeAssistant, Route } from "../types";
import { WindowWithPreloads } from "../data/preloads";
import { storeState } from "../util/ha-pref-storage";
import {
renderLaunchScreenInfoBox,
Expand Down Expand Up @@ -204,7 +205,15 @@ export class HomeAssistantAppEl extends QuickBarMixin(HassElement) {

protected async checkDataBaseMigration() {
if (this.hass?.config?.components.includes("recorder")) {
const info = await getRecorderInfo(this.hass);
let recorderInfoProm: Promise<RecorderInfo> | undefined;
const preloadWindow = window as WindowWithPreloads;
// On first load, we speed up loading page by having recorderInfoProm ready
if (preloadWindow.recorderInfoProm) {
recorderInfoProm = preloadWindow.recorderInfoProm;
preloadWindow.recorderInfoProm = undefined;
}
const info = await (recorderInfoProm ||
getRecorderInfo(this.hass.connection));
this._databaseMigration =
info.migration_in_progress && !info.migration_is_live;
if (this._databaseMigration) {
Expand Down
18 changes: 18 additions & 0 deletions src/panels/config/helpers/forms/ha-schedule-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,20 @@ class HaScheduleForm extends LitElement {
}
}

public disconnectedCallback(): void {
super.disconnectedCallback();
this.calendar?.destroy();
this.calendar = undefined;
this.renderRoot.querySelector("style[data-fullcalendar]")?.remove();
}

public connectedCallback(): void {
super.connectedCallback();
if (this.hasUpdated && !this.calendar) {
this.setupCalendar();
}
}

public focus() {
this.updateComplete.then(
() =>
Expand Down Expand Up @@ -165,6 +179,10 @@ class HaScheduleForm extends LitElement {
}

protected firstUpdated(): void {
this.setupCalendar();
}

private setupCalendar(): void {
const config: CalendarOptions = {
...defaultFullCalendarConfig,
locale: this.hass.language,
Expand Down
Loading
Loading