Make the code flow clearer.

beta
Philippe Pittoli 2024-02-18 02:53:30 +01:00
parent d84c5f789a
commit 529c2edae7
1 changed files with 30 additions and 27 deletions

View File

@ -590,12 +590,21 @@ handleAction = case _ of
state <- H.get state <- H.get
case state.current_page, message of case state.current_page, message of
Home, m@(DNSManager.MkLogged _) -> do 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 case state.store_DomainListInterface_state of
Nothing -> do Nothing -> do
let new_value = DomainListInterface.page_reload (DomainListInterface.initialState unit) m let new_value = DomainListInterface.page_reload (DomainListInterface.initialState unit) m
H.modify_ _ { store_DomainListInterface_state = Just new_value } H.modify_ _ { store_DomainListInterface_state = Just new_value }
Just _ -> handleAction $ Log $ SystemLog "we already have a state? WTH?!" Just _ -> handleAction $ Log $ SystemLog "we already have a state? WTH?!"
revert_old_page = do
-- Get back to the previous page. -- Get back to the previous page.
sessionstorage <- H.liftEffect $ Window.sessionStorage =<< HTML.window sessionstorage <- H.liftEffect $ Window.sessionStorage =<< HTML.window
page <- H.liftEffect $ Storage.getItem "current-page" sessionstorage page <- H.liftEffect $ Storage.getItem "current-page" sessionstorage
@ -606,21 +615,15 @@ handleAction = case _ of
Just "Registration" -> handleAction $ Routing Registration Just "Registration" -> handleAction $ Routing Registration
Just "DomainList" -> handleAction $ Routing DomainList Just "DomainList" -> handleAction $ Routing DomainList
Just "MailValidation" -> handleAction $ Routing MailValidation Just "MailValidation" -> handleAction $ Routing MailValidation
Just "AuthAdmin" -> handleAction $ Routing AuthAdmin
Just "Zone" -> do Just "Zone" -> do
domain <- H.liftEffect $ Storage.getItem "current-zone" sessionstorage domain <- H.liftEffect $ Storage.getItem "current-zone" sessionstorage
case domain of case domain of
Nothing -> handleAction $ Log $ SystemLog "Zone but no domain recorded!! WEIRD" Nothing -> handleAction $ Log $ SystemLog "Zone but no domain recorded!! WEIRD"
Just zone -> do handleAction $ Log $ SystemLog $ "zone to display: " <> zone Just zone -> do handleAction $ Log $ SystemLog $ "zone to display: " <> zone
handleAction $ Routing (Zone zone) handleAction $ Routing (Zone zone)
Just "AuthAdmin" -> handleAction $ Routing AuthAdmin
Just p -> handleAction $ Log $ SystemLog $ "Oopsie, we didn't understand the old page: " <> p 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 :: forall m. MonadEffect m => MonadState State m => ArrayBuffer -> m Unit
--print_json_string arraybuffer = do --print_json_string arraybuffer = do