aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/elm/Persona.elm3
-rw-r--r--src/client/elm/ServerCommunication.elm8
-rw-r--r--src/client/elm/Update.elm5
-rw-r--r--src/client/elm/View/Header.elm4
-rw-r--r--src/client/js/main.js32
5 files changed, 19 insertions, 33 deletions
diff --git a/src/client/elm/Persona.elm b/src/client/elm/Persona.elm
index 51b5fc6..e55d1b2 100644
--- a/src/client/elm/Persona.elm
+++ b/src/client/elm/Persona.elm
@@ -8,7 +8,6 @@ module Persona
type Operation =
NoOp
| SignIn
- | SignOut
operations : Signal.Mailbox Operation
operations = Signal.mailbox NoOp
@@ -17,12 +16,10 @@ fromString : String -> Operation
fromString str =
case str of
"SignIn" -> SignIn
- "SignOut" -> SignOut
_ -> NoOp
toString : Operation -> String
toString operation =
case operation of
SignIn -> "SignIn"
- SignOut -> "SignOut"
_ -> "NoOp"
diff --git a/src/client/elm/ServerCommunication.elm b/src/client/elm/ServerCommunication.elm
index 74b45e8..62644f8 100644
--- a/src/client/elm/ServerCommunication.elm
+++ b/src/client/elm/ServerCommunication.elm
@@ -14,13 +14,11 @@ import Debug
import SimpleHTTP exposing (..)
-import Persona exposing (operations)
-
import Model.User exposing (UserId)
import Model.Payment exposing (..)
import Model.View.LoggedIn.Add exposing (Frequency(..))
-import Update as U
+import Update as U exposing (actions)
import Update.SignIn exposing (..)
import Update.LoggedIn as UL
import Update.LoggedIn.Monthly as UM
@@ -51,10 +49,6 @@ sendRequest communication =
SignIn assertion ->
post ("/signIn?assertion=" ++ assertion)
|> flip Task.andThen (always initViewAction)
- |> flip Task.onError (\err ->
- Signal.send operations.address Persona.SignOut
- |> flip Task.andThen (always <| Task.fail err)
- )
AddPayment name cost ->
post (addPaymentURL name cost Punctual)
diff --git a/src/client/elm/Update.elm b/src/client/elm/Update.elm
index ed4b99d..62782a3 100644
--- a/src/client/elm/Update.elm
+++ b/src/client/elm/Update.elm
@@ -20,10 +20,11 @@ import Update.LoggedIn exposing (..)
type Action =
NoOp
| UpdateTime Time
+ | GoLoadingView
| GoSignInView
+ | GoLoggedInView Users UserId Payments Payments Int Payers
| SignInError String
| UpdateSignIn SignInAction
- | GoLoggedInView Users UserId Payments Payments Int Payers
| UpdateLoggedIn LoggedAction
actions : Signal.Mailbox Action
@@ -36,6 +37,8 @@ updateModel action model =
model
UpdateTime time ->
{ model | currentTime = time }
+ GoLoadingView ->
+ { model | view = V.LoadingView }
GoSignInView ->
{ model | view = V.SignInView initSignInView }
GoLoggedInView users me monthlyPayments payments paymentsCount payers ->
diff --git a/src/client/elm/View/Header.elm b/src/client/elm/View/Header.elm
index 94bdb01..0cc2137 100644
--- a/src/client/elm/View/Header.elm
+++ b/src/client/elm/View/Header.elm
@@ -6,7 +6,7 @@ import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
-import Persona exposing (operations)
+import ServerCommunication as SC exposing (serverCommunications)
import Model exposing (Model)
import Model.View exposing (..)
@@ -25,7 +25,7 @@ renderHeader model =
LoggedInView _ ->
button
[ class "icon"
- , onClick operations.address Persona.SignOut
+ , onClick serverCommunications.address SC.SignOut
]
[ renderIcon "power-off" ]
_ ->
diff --git a/src/client/js/main.js b/src/client/js/main.js
index 12593e6..5fd73ea 100644
--- a/src/client/js/main.js
+++ b/src/client/js/main.js
@@ -5,24 +5,16 @@ var app = Elm.fullscreen(Elm.Main, {
sign: null
});
-navigator.id.watch({
- loggedInUser: null,
- onlogin: function(assertion) {
- app.ports.sign.send({
- operation: 'SignIn',
- assertion: assertion
- });
- },
- onlogout: function() {}
-});
-
-app.ports.persona.subscribe(function(communication) {
- if(communication === 'SignIn') {
- navigator.id.request();
- } else if(communication === 'SignOut') {
- navigator.id.logout();
- app.ports.sign.send({
- operation: 'SignOut'
- });
- }
+app.ports.persona.subscribe(function() {
+ navigator.id.watch({
+ loggedInUser: null,
+ onlogin: function(assertion) {
+ app.ports.sign.send({
+ operation: 'SignIn',
+ assertion: assertion
+ });
+ },
+ onlogout: function() {}
+ });
+ navigator.id.request();
});