Skip to content

Commit

Permalink
fix: 🐛 lines not connecting when no battery connected
Browse files Browse the repository at this point in the history
  • Loading branch information
flixlix committed Jan 15, 2024
1 parent 37acd35 commit 09072f0
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/components/flows/batteryGrid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { showLine } from "../../utils/showLine";
import { html, svg } from "lit";
import { styleLine } from "../../utils/styleLine";
import { type Flows } from "./index";
import { checkHasRightIndividual } from "../../utils/computeIndividualPosition";
import { checkHasBottomIndividual, checkHasRightIndividual } from "../../utils/computeIndividualPosition";

type FlowBatteryGridFlows = Pick<Flows, Exclude<keyof Flows, "solar">>;

export const flowBatteryGrid = (config: PowerFlowCardPlusConfig, { battery, grid, individual, newDur }: FlowBatteryGridFlows) => {
return grid.has && battery.has && showLine(config, Math.max(grid.state.toBattery || 0, battery.state.toGrid || 0))
? html`<div
class="lines ${classMap({
high: battery.has,
high: battery.has || checkHasBottomIndividual(config, individual),
"individual1-individual2": !battery.has && individual.every((i) => i?.has),
"multi-individual": checkHasRightIndividual(config, individual),
})}"
Expand Down
4 changes: 2 additions & 2 deletions src/components/flows/batteryToHome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { showLine } from "../../utils/showLine";
import { html, svg } from "lit";
import { styleLine } from "../../utils/styleLine";
import { type Flows } from "./index";
import { checkHasRightIndividual } from "../../utils/computeIndividualPosition";
import { checkHasBottomIndividual, checkHasRightIndividual } from "../../utils/computeIndividualPosition";

type FlowBatteryToHomeFlows = Pick<Flows, Exclude<keyof Flows, "solar">>;

export const flowBatteryToHome = (config: PowerFlowCardPlusConfig, { battery, grid, individual, newDur }: FlowBatteryToHomeFlows) => {
return battery.has && showLine(config, battery.state.toHome)
? html`<div
class="lines ${classMap({
high: battery.has,
high: battery.has || checkHasBottomIndividual(config, individual),
"individual1-individual2": !battery.has && individual.every((i) => i?.has),
"multi-individual": checkHasRightIndividual(config, individual),
})}"
Expand Down
4 changes: 2 additions & 2 deletions src/components/flows/gridToHome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { showLine } from "../../utils/showLine";
import { html, svg } from "lit";
import { styleLine } from "../../utils/styleLine";
import { type Flows } from "./index";
import { checkHasRightIndividual } from "../../utils/computeIndividualPosition";
import { checkHasBottomIndividual, checkHasRightIndividual } from "../../utils/computeIndividualPosition";

export const flowGridToHome = (config: PowerFlowCardPlusConfig, { battery, grid, individual, solar, newDur }: Flows) => {
return grid.has && showLine(config, grid.state.fromGrid)
? html`<div
class="lines ${classMap({
high: battery.has,
high: battery.has || checkHasBottomIndividual(config, individual),
"individual1-individual2": !battery.has && individual.every((i) => i?.has),
"multi-individual": checkHasRightIndividual(config, individual),
})}"
Expand Down
4 changes: 2 additions & 2 deletions src/components/flows/solarToBattery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { showLine } from "../../utils/showLine";
import { html, svg } from "lit";
import { styleLine } from "../../utils/styleLine";
import { type Flows } from "./index";
import { checkHasRightIndividual } from "../../utils/computeIndividualPosition";
import { checkHasBottomIndividual, checkHasRightIndividual } from "../../utils/computeIndividualPosition";

type FlowSolarToBatteryFlows = Pick<Flows, Exclude<keyof Flows, "grid">>;

export const flowSolarToBattery = (config: PowerFlowCardPlusConfig, { battery, individual, solar, newDur }: FlowSolarToBatteryFlows) => {
return battery.has && solar.has && showLine(config, solar.state.toBattery || 0)
? html`<div
class="lines ${classMap({
high: battery.has,
high: battery.has || checkHasBottomIndividual(config, individual),
"individual1-individual2": !battery.has && individual.every((i) => i?.has),
"multi-individual": checkHasRightIndividual(config, individual),
})}"
Expand Down
4 changes: 2 additions & 2 deletions src/components/flows/solarToGrid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { showLine } from "../../utils/showLine";
import { html, svg } from "lit";
import { styleLine } from "../../utils/styleLine";
import { type Flows } from "./index";
import { checkHasRightIndividual } from "../../utils/computeIndividualPosition";
import { checkHasBottomIndividual, checkHasRightIndividual } from "../../utils/computeIndividualPosition";

export const flowSolarToGrid = (config: PowerFlowCardPlusConfig, { battery, grid, individual, solar, newDur }: Flows) => {
return grid.hasReturnToGrid && solar.has && showLine(config, solar.state.toGrid || 0)
? html`<div
class="lines ${classMap({
high: battery.has,
high: battery.has || checkHasBottomIndividual(config, individual),
"individual1-individual2": !battery.has && individual.every((i) => i?.has),
"multi-individual": checkHasRightIndividual(config, individual),
})}"
Expand Down
2 changes: 1 addition & 1 deletion src/utils/computeIndividualPosition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ export const checkHasRightIndividual = (config: PowerFlowCardPlusConfig, individ
!!getTopRightIndividual(config, individualObjs) || !!getBottomRightIndividual(config, individualObjs);

export const checkHasBottomIndividual = (config: PowerFlowCardPlusConfig, individualObjs: IndividualObject[]): boolean =>
!!getBottomLeftIndividual(config, individualObjs) || !!getBottomRightIndividual(config, individualObjs);
!!getBottomLeftIndividual(config, individualObjs) || !!getBottomRightIndividual(config, individualObjs);

0 comments on commit 09072f0

Please sign in to comment.