Skip to content

Commit d1e6599

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 f228fbe commit d1e6599

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
@@ -1534,13 +1534,13 @@ defmodule TeslaMate.Vehicles.Vehicle do
15341534
:online ->
15351535
true
15361536

1537-
:driving when data.current_drive != nil ->
1537+
:driving ->
15381538
true
15391539

1540-
:updating when data.current_update != nil ->
1540+
:updating ->
15411541
true
15421542

1543-
:charging when data.current_charging_process != nil ->
1543+
:charging ->
15441544
true
15451545

15461546
:start ->
@@ -1566,9 +1566,9 @@ defmodule TeslaMate.Vehicles.Vehicle do
15661566
reachable? =
15671567
case expected_state do
15681568
:online -> true
1569-
:driving when data.current_drive != nil -> true
1570-
:updating when data.current_update != nil -> true
1571-
:charging when data.current_charging_process != nil -> true
1569+
:driving -> true
1570+
:updating -> true
1571+
:charging -> true
15721572
:start -> false
15731573
{:offline, _} -> false
15741574
{:asleep, _} -> false

0 commit comments

Comments
 (0)