diff options
Diffstat (limited to 'scratch')
-rw-r--r-- | scratch/habit-screens/client/src/Main.elm | 4 | ||||
-rw-r--r-- | scratch/habit-screens/client/src/State.elm | 6 |
2 files changed, 8 insertions, 2 deletions
diff --git a/scratch/habit-screens/client/src/Main.elm b/scratch/habit-screens/client/src/Main.elm index d2b36a33f322..2ddedb913357 100644 --- a/scratch/habit-screens/client/src/Main.elm +++ b/scratch/habit-screens/client/src/Main.elm @@ -4,11 +4,13 @@ import Browser import Habits import Html exposing (..) import State +import Time subscriptions : State.Model -> Sub State.Msg subscriptions model = - Sub.none + -- once per minute + Time.every (1000 * 60) (\_ -> State.MaybeAdjustWeekday) view : State.Model -> Html State.Msg 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 ) |