mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-29 20:26:39 +00:00
Calendar Card: Fix Calendar not updating events on config change (#7165)
This commit is contained in:
parent
10d71587e7
commit
4f5b4d4472
@ -71,6 +71,10 @@ export class HuiCalendarCard extends LitElement implements LovelaceCard {
|
|||||||
|
|
||||||
@internalProperty() private _veryNarrow = false;
|
@internalProperty() private _veryNarrow = false;
|
||||||
|
|
||||||
|
private _startDate?: Date;
|
||||||
|
|
||||||
|
private _endDate?: Date;
|
||||||
|
|
||||||
private _resizeObserver?: ResizeObserver;
|
private _resizeObserver?: ResizeObserver;
|
||||||
|
|
||||||
public setConfig(config: CalendarCardConfig): void {
|
public setConfig(config: CalendarCardConfig): void {
|
||||||
@ -89,6 +93,10 @@ export class HuiCalendarCard extends LitElement implements LovelaceCard {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (this._config?.entities !== config.entities) {
|
||||||
|
this._fetchCalendarEvents();
|
||||||
|
}
|
||||||
|
|
||||||
this._config = { initial_view: "dayGridMonth", ...config };
|
this._config = { initial_view: "dayGridMonth", ...config };
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,13 +160,21 @@ export class HuiCalendarCard extends LitElement implements LovelaceCard {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _handleViewChanged(
|
private _handleViewChanged(ev: HASSDomEvent<CalendarViewChanged>): void {
|
||||||
ev: HASSDomEvent<CalendarViewChanged>
|
this._startDate = ev.detail.start;
|
||||||
): Promise<void> {
|
this._endDate = ev.detail.end;
|
||||||
|
this._fetchCalendarEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async _fetchCalendarEvents(): Promise<void> {
|
||||||
|
if (!this._startDate || !this._endDate) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this._events = await fetchCalendarEvents(
|
this._events = await fetchCalendarEvents(
|
||||||
this.hass!,
|
this.hass!,
|
||||||
ev.detail.start,
|
this._startDate,
|
||||||
ev.detail.end,
|
this._endDate,
|
||||||
this._calendars
|
this._calendars
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user