mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-29 12:16: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;
|
||||
|
||||
private _startDate?: Date;
|
||||
|
||||
private _endDate?: Date;
|
||||
|
||||
private _resizeObserver?: ResizeObserver;
|
||||
|
||||
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 };
|
||||
}
|
||||
|
||||
@ -152,13 +160,21 @@ export class HuiCalendarCard extends LitElement implements LovelaceCard {
|
||||
}
|
||||
}
|
||||
|
||||
private async _handleViewChanged(
|
||||
ev: HASSDomEvent<CalendarViewChanged>
|
||||
): Promise<void> {
|
||||
private _handleViewChanged(ev: HASSDomEvent<CalendarViewChanged>): void {
|
||||
this._startDate = ev.detail.start;
|
||||
this._endDate = ev.detail.end;
|
||||
this._fetchCalendarEvents();
|
||||
}
|
||||
|
||||
private async _fetchCalendarEvents(): Promise<void> {
|
||||
if (!this._startDate || !this._endDate) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._events = await fetchCalendarEvents(
|
||||
this.hass!,
|
||||
ev.detail.start,
|
||||
ev.detail.end,
|
||||
this._startDate,
|
||||
this._endDate,
|
||||
this._calendars
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user