mirror of
https://github.com/home-assistant/frontend.git
synced 2025-12-20 02:38:53 +00:00
Fix calendar card not showing different colors for multiple calendars (#28338)
This commit is contained in:
@@ -80,12 +80,6 @@ export class HuiCalendarCard extends LitElement implements LovelaceCard {
|
|||||||
throw new Error("Entities need to be an array");
|
throw new Error("Entities need to be an array");
|
||||||
}
|
}
|
||||||
|
|
||||||
const computedStyles = getComputedStyle(this);
|
|
||||||
this._calendars = config!.entities.map((entity, idx) => ({
|
|
||||||
entity_id: entity,
|
|
||||||
backgroundColor: getColorByIndex(idx, computedStyles),
|
|
||||||
}));
|
|
||||||
|
|
||||||
if (this._config?.entities !== config.entities) {
|
if (this._config?.entities !== config.entities) {
|
||||||
this._fetchCalendarEvents();
|
this._fetchCalendarEvents();
|
||||||
}
|
}
|
||||||
@@ -93,6 +87,20 @@ export class HuiCalendarCard extends LitElement implements LovelaceCard {
|
|||||||
this._config = { initial_view: "dayGridMonth", ...config };
|
this._config = { initial_view: "dayGridMonth", ...config };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public willUpdate(changedProps: PropertyValues): void {
|
||||||
|
super.willUpdate(changedProps);
|
||||||
|
if (
|
||||||
|
!this.hasUpdated ||
|
||||||
|
(changedProps.has("_config") && this._config?.entities)
|
||||||
|
) {
|
||||||
|
const computedStyles = getComputedStyle(this);
|
||||||
|
this._calendars = this._config!.entities.map((entity, idx) => ({
|
||||||
|
entity_id: entity,
|
||||||
|
backgroundColor: getColorByIndex(idx, computedStyles),
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public getCardSize(): number {
|
public getCardSize(): number {
|
||||||
return 12;
|
return 12;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user