mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-31 13:07:49 +00:00
name change + comment
This commit is contained in:
parent
2df3041b49
commit
59b5b0f9dd
@ -13,7 +13,8 @@ export const SubscribeMixin = <T extends Constructor<ReactiveElement>>(
|
||||
class SubscribeClass extends superClass {
|
||||
@property({ attribute: false }) public hass?: HomeAssistant;
|
||||
|
||||
protected hassSubscribeNeedsProperties?: string[];
|
||||
// we wait with subscribing till these properties are set on the host element
|
||||
protected hassSubscribeRequiredHostProps?: string[];
|
||||
|
||||
private __unsubs?: Array<UnsubscribeFunc | Promise<UnsubscribeFunc>>;
|
||||
|
||||
@ -43,11 +44,11 @@ export const SubscribeMixin = <T extends Constructor<ReactiveElement>>(
|
||||
this.__checkSubscribed();
|
||||
return;
|
||||
}
|
||||
if (!this.hassSubscribeNeedsProperties) {
|
||||
if (!this.hassSubscribeRequiredHostProps) {
|
||||
return;
|
||||
}
|
||||
for (const key of changedProps.keys()) {
|
||||
if (this.hassSubscribeNeedsProperties.includes(key as string)) {
|
||||
if (this.hassSubscribeRequiredHostProps.includes(key as string)) {
|
||||
this.__checkSubscribed();
|
||||
return;
|
||||
}
|
||||
@ -65,7 +66,7 @@ export const SubscribeMixin = <T extends Constructor<ReactiveElement>>(
|
||||
this.__unsubs !== undefined ||
|
||||
!(this as unknown as Element).isConnected ||
|
||||
this.hass === undefined ||
|
||||
this.hassSubscribeNeedsProperties?.some(
|
||||
this.hassSubscribeRequiredHostProps?.some(
|
||||
(prop) => this[prop] === undefined
|
||||
)
|
||||
) {
|
||||
|
@ -32,7 +32,7 @@ class HuiEnergyCarbonGaugeCard
|
||||
|
||||
@state() private _data?: EnergyData;
|
||||
|
||||
protected hassSubscribeNeedsProperties = ["_config"];
|
||||
protected hassSubscribeRequiredHostProps = ["_config"];
|
||||
|
||||
public getCardSize(): number {
|
||||
return 4;
|
||||
|
@ -49,7 +49,7 @@ export class HuiEnergyDevicesGraphCard
|
||||
|
||||
@query("ha-chart-base") private _chart?: HaChartBase;
|
||||
|
||||
protected hassSubscribeNeedsProperties = ["_config"];
|
||||
protected hassSubscribeRequiredHostProps = ["_config"];
|
||||
|
||||
public hassSubscribe(): UnsubscribeFunc[] {
|
||||
return [
|
||||
|
@ -43,7 +43,7 @@ class HuiEnergyDistrubutionCard
|
||||
|
||||
@state() private _data?: EnergyData;
|
||||
|
||||
protected hassSubscribeNeedsProperties = ["_config"];
|
||||
protected hassSubscribeRequiredHostProps = ["_config"];
|
||||
|
||||
public setConfig(config: EnergyDistributionCardConfig): void {
|
||||
this._config = config;
|
||||
|
@ -62,7 +62,7 @@ export class HuiEnergyGasGraphCard
|
||||
|
||||
@state() private _unit?: string;
|
||||
|
||||
protected hassSubscribeNeedsProperties = ["_config"];
|
||||
protected hassSubscribeRequiredHostProps = ["_config"];
|
||||
|
||||
public hassSubscribe(): UnsubscribeFunc[] {
|
||||
return [
|
||||
|
@ -35,7 +35,7 @@ class HuiEnergyGridGaugeCard
|
||||
|
||||
@state() private _data?: EnergyData;
|
||||
|
||||
protected hassSubscribeNeedsProperties = ["_config"];
|
||||
protected hassSubscribeRequiredHostProps = ["_config"];
|
||||
|
||||
public hassSubscribe(): UnsubscribeFunc[] {
|
||||
return [
|
||||
|
@ -30,7 +30,7 @@ class HuiEnergySolarGaugeCard
|
||||
|
||||
@state() private _data?: EnergyData;
|
||||
|
||||
protected hassSubscribeNeedsProperties = ["_config"];
|
||||
protected hassSubscribeRequiredHostProps = ["_config"];
|
||||
|
||||
public hassSubscribe(): UnsubscribeFunc[] {
|
||||
return [
|
||||
|
@ -61,7 +61,7 @@ export class HuiEnergySolarGraphCard
|
||||
|
||||
@state() private _end = endOfToday();
|
||||
|
||||
protected hassSubscribeNeedsProperties = ["_config"];
|
||||
protected hassSubscribeRequiredHostProps = ["_config"];
|
||||
|
||||
public hassSubscribe(): UnsubscribeFunc[] {
|
||||
return [
|
||||
|
@ -45,7 +45,7 @@ export class HuiEnergySourcesTableCard
|
||||
|
||||
@state() private _data?: EnergyData;
|
||||
|
||||
protected hassSubscribeNeedsProperties = ["_config"];
|
||||
protected hassSubscribeRequiredHostProps = ["_config"];
|
||||
|
||||
public hassSubscribe(): UnsubscribeFunc[] {
|
||||
return [
|
||||
|
@ -50,7 +50,7 @@ export class HuiEnergyUsageGraphCard
|
||||
|
||||
@state() private _end = endOfToday();
|
||||
|
||||
protected hassSubscribeNeedsProperties = ["_config"];
|
||||
protected hassSubscribeRequiredHostProps = ["_config"];
|
||||
|
||||
public hassSubscribe(): UnsubscribeFunc[] {
|
||||
return [
|
||||
|
Loading…
x
Reference in New Issue
Block a user