Skip to content

Commit

Permalink
Merge pull request #464 from flixlix/fix-462-bug-lines-in-the-wrong-p…
Browse files Browse the repository at this point in the history
…lace

fix: 🐛 lines not connecting when no battery connected
  • Loading branch information
flixlix authored Jan 15, 2024
2 parents 1139574 + a2eceb8 commit b3b0c2b
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,7 +4,7 @@ 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";
import { checkShouldShowDots } from "../../utils/checkShouldShowDots";

type FlowBatteryGridFlows = Pick<Flows, Exclude<keyof Flows, "solar">>;
Expand All @@ -13,7 +13,7 @@ export const flowBatteryGrid = (config: PowerFlowCardPlusConfig, { battery, grid
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,7 +4,7 @@ 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";
import { checkShouldShowDots } from "../../utils/checkShouldShowDots";

type FlowBatteryToHomeFlows = Pick<Flows, Exclude<keyof Flows, "solar">>;
Expand All @@ -13,7 +13,7 @@ export const flowBatteryToHome = (config: PowerFlowCardPlusConfig, { battery, gr
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,14 +4,14 @@ 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";
import { checkShouldShowDots } from "../../utils/checkShouldShowDots";

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,7 +4,7 @@ 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";
import { checkShouldShowDots } from "../../utils/checkShouldShowDots";

type FlowSolarToBatteryFlows = Pick<Flows, Exclude<keyof Flows, "grid">>;
Expand All @@ -13,7 +13,7 @@ export const flowSolarToBattery = (config: PowerFlowCardPlusConfig, { battery, i
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,14 +4,14 @@ 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";
import { checkShouldShowDots } from "../../utils/checkShouldShowDots";

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 b3b0c2b

Please sign in to comment.