Store the AuthenticationDaemonAdminInterface state, too.
This commit is contained in:
parent
f6f78f49ed
commit
796cd3ea55
@ -31,11 +31,14 @@ import App.Messages.AuthenticationDaemon as AuthD
|
||||
data Output
|
||||
= MessageToSend ArrayBuffer
|
||||
| Log LogMessage
|
||||
| AskState
|
||||
| StoreState State
|
||||
|
||||
data Query a
|
||||
= MessageReceived ArrayBuffer a
|
||||
| ConnectionIsDown a
|
||||
| ConnectionIsUp a
|
||||
| ProvideState (Maybe State) a
|
||||
|
||||
type Slot = H.Slot Query Output
|
||||
|
||||
@ -51,9 +54,11 @@ data Action
|
||||
= HandleAddUserInput AddUserInput
|
||||
|
||||
| AddUserAttempt
|
||||
-- | Finalize
|
||||
| PreventSubmit Event
|
||||
|
||||
| Initialize
|
||||
| Finalize
|
||||
|
||||
type StateAddUserForm = { login :: String, admin :: Boolean, email :: String, pass :: String }
|
||||
|
||||
type State =
|
||||
@ -67,9 +72,10 @@ component =
|
||||
{ initialState
|
||||
, render
|
||||
, eval: H.mkEval $ H.defaultEval
|
||||
{ handleAction = handleAction
|
||||
{ initialize = Just Initialize
|
||||
, handleAction = handleAction
|
||||
, handleQuery = handleQuery
|
||||
-- , finalize = Just Finalize
|
||||
, finalize = Just Finalize
|
||||
}
|
||||
}
|
||||
|
||||
@ -123,6 +129,12 @@ render { addUserForm, wsUp }
|
||||
|
||||
handleAction :: forall m. MonadAff m => Action -> H.HalogenM State Action () Output m Unit
|
||||
handleAction = case _ of
|
||||
Initialize -> do
|
||||
H.raise $ AskState
|
||||
|
||||
Finalize -> do
|
||||
state <- H.get
|
||||
H.raise $ StoreState state
|
||||
|
||||
HandleAddUserInput adduserinp -> do
|
||||
{ addUserForm } <- H.get
|
||||
@ -162,6 +174,13 @@ handleAction = case _ of
|
||||
handleQuery :: forall a m. MonadAff m => Query a -> H.HalogenM State Action () Output m (Maybe a)
|
||||
handleQuery = case _ of
|
||||
|
||||
ProvideState maybe_state a -> do
|
||||
case maybe_state of
|
||||
Nothing -> pure Nothing
|
||||
Just s -> do
|
||||
H.put s
|
||||
pure (Just a)
|
||||
|
||||
MessageReceived message a -> do
|
||||
receivedMessage <- H.liftEffect $ AuthD.deserialize message
|
||||
case receivedMessage of
|
||||
|
@ -36,6 +36,7 @@ type State = { token :: Maybe String
|
||||
, uid :: Maybe Int
|
||||
, current_page :: Page
|
||||
, store_DomainListInterface_state :: Maybe DomainListInterface.State
|
||||
, store_AuthenticationDaemonAdmin_state :: Maybe AAI.State
|
||||
}
|
||||
|
||||
type ChildSlots =
|
||||
@ -67,6 +68,7 @@ initialState _ = { token: Nothing
|
||||
, uid: Nothing
|
||||
, current_page: Home
|
||||
, store_DomainListInterface_state: Nothing
|
||||
, store_AuthenticationDaemonAdmin_state: Nothing
|
||||
}
|
||||
|
||||
render :: forall m. MonadAff m => State -> H.ComponentHTML Action ChildSlots m
|
||||
@ -159,8 +161,12 @@ handleAction = case _ of
|
||||
AF.Log message -> H.tell _log unit (Log.Log message)
|
||||
|
||||
AuthenticationDaemonAdminComponentEvent ev -> case ev of
|
||||
AAI.MessageToSend message -> H.tell _ws_auth unit (WS.ToSend message)
|
||||
AAI.Log message -> H.tell _log unit (Log.Log message)
|
||||
AAI.MessageToSend message -> H.tell _ws_auth unit (WS.ToSend message)
|
||||
AAI.Log message -> H.tell _log unit (Log.Log message)
|
||||
AAI.StoreState s -> H.modify_ _ { store_AuthenticationDaemonAdmin_state = Just s }
|
||||
AAI.AskState -> do
|
||||
state <- H.get
|
||||
H.tell _aai unit (AAI.ProvideState state.store_AuthenticationDaemonAdmin_state)
|
||||
|
||||
DomainListComponentEvent ev -> case ev of
|
||||
DomainListInterface.MessageToSend message -> H.tell _ws_dns unit (WS.ToSend message)
|
||||
|
Loading…
Reference in New Issue
Block a user