Skip to content

Commit 96e4597

Browse files
committed
Remove redundant guards from fetch state matching
The guards 'when data.current_drive != nil' etc. on the simple atom patterns ':driving', ':updating', ':charging' are unnecessary. The state atom itself is the source of truth - if we're in ':driving', the dual-write invariant guarantees current_drive is populated. The guards added nothing over the atom pattern match.
1 parent a0bbb6b commit 96e4597

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

lib/teslamate/vehicles/vehicle.ex

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1517,13 +1517,13 @@ defmodule TeslaMate.Vehicles.Vehicle do
15171517
:online ->
15181518
true
15191519

1520-
:driving when data.current_drive != nil ->
1520+
:driving ->
15211521
true
15221522

1523-
:updating when data.current_update != nil ->
1523+
:updating ->
15241524
true
15251525

1526-
:charging when data.current_charging_process != nil ->
1526+
:charging ->
15271527
true
15281528

15291529
:start ->
@@ -1549,9 +1549,9 @@ defmodule TeslaMate.Vehicles.Vehicle do
15491549
reachable? =
15501550
case expected_state do
15511551
:online -> true
1552-
:driving when data.current_drive != nil -> true
1553-
:updating when data.current_update != nil -> true
1554-
:charging when data.current_charging_process != nil -> true
1552+
:driving -> true
1553+
:updating -> true
1554+
:charging -> true
15551555
:start -> false
15561556
{:offline, _} -> false
15571557
{:asleep, _} -> false

0 commit comments

Comments
 (0)