about summary refs log tree commit diff
path: root/scratch/habit-screens/client/src/State.elm
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2020-10-10T16·33+0100
committerWilliam Carroll <wpcarro@gmail.com>2020-10-10T16·34+0100
commit487232d1aac6273ae911576a595b5c332c4ed0ca (patch)
treea931d41f22a653480fc1583f00cdf9ef55a51638 /scratch/habit-screens/client/src/State.elm
parent7d425de48d395e2f81a62efccbcacc734572bb18 (diff)
Ensure weekday is updated
This ensures us that our view is consistent within ~1 minute of reality.
Diffstat (limited to 'scratch/habit-screens/client/src/State.elm')
-rw-r--r--scratch/habit-screens/client/src/State.elm6
1 files changed, 5 insertions, 1 deletions
diff --git a/scratch/habit-screens/client/src/State.elm b/scratch/habit-screens/client/src/State.elm
index 9e594f9a2462..5bfa5c92802b 100644
--- a/scratch/habit-screens/client/src/State.elm
+++ b/scratch/habit-screens/client/src/State.elm
@@ -11,6 +11,7 @@ type Msg
     | SetView View
     | ReceiveDate Date.Date
     | ToggleHabit Int
+    | MaybeAdjustWeekday
 
 
 type View
@@ -65,7 +66,7 @@ update msg ({ completed } as model) =
             )
 
         ReceiveDate x ->
-            ( { model | dayOfWeek = Just Sun }, Cmd.none )
+            ( { model | dayOfWeek = Just (Date.weekday x) }, Cmd.none )
 
         ToggleHabit i ->
             ( { model
@@ -78,3 +79,6 @@ update msg ({ completed } as model) =
               }
             , Cmd.none
             )
+
+        MaybeAdjustWeekday ->
+            ( model, Date.today |> Task.perform ReceiveDate )