Make the code flow clearer.
parent
d84c5f789a
commit
529c2edae7
|
@ -590,12 +590,21 @@ handleAction = case _ of
|
|||
state <- H.get
|
||||
case state.current_page, message of
|
||||
Home, m@(DNSManager.MkLogged _) -> do
|
||||
update_domain_list state m
|
||||
revert_old_page
|
||||
DomainList, _ -> H.tell _dli unit (DomainListInterface.MessageReceived message)
|
||||
Zone _ , _ -> H.tell _zi unit (ZoneInterface.MessageReceived message)
|
||||
_, _ -> handleAction $ Log $ SystemLog "unexpected message from dnsmanagerd"
|
||||
pure unit
|
||||
where
|
||||
update_domain_list state m = do
|
||||
case state.store_DomainListInterface_state of
|
||||
Nothing -> do
|
||||
let new_value = DomainListInterface.page_reload (DomainListInterface.initialState unit) m
|
||||
H.modify_ _ { store_DomainListInterface_state = Just new_value }
|
||||
Just _ -> handleAction $ Log $ SystemLog "we already have a state? WTH?!"
|
||||
|
||||
revert_old_page = do
|
||||
-- Get back to the previous page.
|
||||
sessionstorage <- H.liftEffect $ Window.sessionStorage =<< HTML.window
|
||||
page <- H.liftEffect $ Storage.getItem "current-page" sessionstorage
|
||||
|
@ -606,21 +615,15 @@ handleAction = case _ of
|
|||
Just "Registration" -> handleAction $ Routing Registration
|
||||
Just "DomainList" -> handleAction $ Routing DomainList
|
||||
Just "MailValidation" -> handleAction $ Routing MailValidation
|
||||
|
||||
Just "AuthAdmin" -> handleAction $ Routing AuthAdmin
|
||||
Just "Zone" -> do
|
||||
domain <- H.liftEffect $ Storage.getItem "current-zone" sessionstorage
|
||||
case domain of
|
||||
Nothing -> handleAction $ Log $ SystemLog "Zone but no domain recorded!! WEIRD"
|
||||
Just zone -> do handleAction $ Log $ SystemLog $ "zone to display: " <> zone
|
||||
handleAction $ Routing (Zone zone)
|
||||
|
||||
Just "AuthAdmin" -> handleAction $ Routing AuthAdmin
|
||||
Just p -> handleAction $ Log $ SystemLog $ "Oopsie, we didn't understand the old page: " <> p
|
||||
|
||||
DomainList, _ -> H.tell _dli unit (DomainListInterface.MessageReceived message)
|
||||
Zone _ , _ -> H.tell _zi unit (ZoneInterface.MessageReceived message)
|
||||
_, _ -> handleAction $ Log $ SystemLog "unexpected message from dnsmanagerd"
|
||||
pure unit
|
||||
|
||||
--print_json_string :: forall m. MonadEffect m => MonadState State m => ArrayBuffer -> m Unit
|
||||
--print_json_string arraybuffer = do
|
||||
|
|
Loading…
Reference in New Issue