about summary refs log tree commit diff
path: root/client
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2020-08-02T10·13+0100
committerWilliam Carroll <wpcarro@gmail.com>2020-08-02T10·13+0100
commitd5bc6f963d4c8cdb8990a9946d9a142a32e13d3c (patch)
tree2dae4ccfef930e0dcb98ddd3b34489510764fdfb /client
parent57b6472e2fbd963cc18237d596eb61bb767a1206 (diff)
Protect views from a State with an empty Session
This should simplify UserHome among other views.
Diffstat (limited to 'client')
-rw-r--r--client/src/Common.elm10
1 files changed, 10 insertions, 0 deletions
diff --git a/client/src/Common.elm b/client/src/Common.elm
index a3106114d43a..63ba97b794ac 100644
--- a/client/src/Common.elm
+++ b/client/src/Common.elm
@@ -25,3 +25,13 @@ allErrors model =
                                 }
                 )
         )
+
+
+withSession : State.Model -> (State.Session -> Html State.Msg) -> Html State.Msg
+withSession model renderWithSession =
+    case model.session of
+        Nothing ->
+            div [] [ UI.paragraph "You need a valid session to view this page. Please attempt to log in." ]
+
+        Just session ->
+            renderWithSession session