Big reconnection button is now working.

beta
Philippe Pittoli 2024-11-13 02:44:43 +01:00
parent db8cd669ae
commit 346a23b8f7
2 changed files with 17 additions and 5 deletions

View File

@ -129,6 +129,9 @@ data Action
-- | then return to the home page. -- | then return to the home page.
| Disconnection | Disconnection
-- | Reconnection to both `authd` and `dnsmanagerd`.
| Reconnection
-- | Try to authenticate the user to `dnsmanagerd`. -- | Try to authenticate the user to `dnsmanagerd`.
| AuthenticateToDNSManager | AuthenticateToDNSManager
@ -271,11 +274,11 @@ render state
, Bulma.column_ [ Bulma.level [ render_auth_WS, render_dnsmanager_WS ] [] ] ] , Bulma.column_ [ Bulma.level [ render_auth_WS, render_dnsmanager_WS ] [] ] ]
] ]
where where
reconnection_bar :: forall w i. HH.HTML w i reconnection_bar :: forall w. HH.HTML w Action
reconnection_bar = reconnection_bar =
if (state.are_we_connected_to_authd && state.are_we_connected_to_dnsmanagerd) if (state.are_we_connected_to_authd && state.are_we_connected_to_dnsmanagerd)
then Bulma.p "yay, you're connected" then HH.div_ []
else Bulma.p "OH NOES :(" else Bulma.btn_ (C.is_large <> C.is_danger) "You are disconnected. Click here to reconnect." Reconnection
render_auth_WS :: forall monad. MonadAff monad => H.ComponentHTML Action ChildSlots monad render_auth_WS :: forall monad. MonadAff monad => H.ComponentHTML Action ChildSlots monad
render_auth_WS = HH.slot _ws_auth unit WS.component (Tuple "ws://127.0.0.1:8080" "authd") AuthenticationDaemonEvent render_auth_WS = HH.slot _ws_auth unit WS.component (Tuple "ws://127.0.0.1:8080" "authd") AuthenticationDaemonEvent
@ -682,6 +685,10 @@ handleAction = case _ of
CloseNotif -> do CloseNotif -> do
H.modify_ _ { notif = NoNotification } H.modify_ _ { notif = NoNotification }
Reconnection -> do
H.tell _ws_auth unit WS.Connect
H.tell _ws_dns unit WS.Connect
Disconnection -> do Disconnection -> do
handleAction $ Routing Home handleAction $ Routing Home

View File

@ -229,6 +229,11 @@ handleQuery = case _ of
pure (Just a) pure (Just a)
-- Sending a keepalive: do not tell the parent to reset the keepalive counter. -- Sending a keepalive: do not tell the parent to reset the keepalive counter.
ToSendKeepAlive message a -> do ToSendKeepAlive message a -> do
-- In case a KeepAlive is sent while the connection is down, just ignore it.
state <- H.get
case state.wsInfo.connection of
Nothing -> pure Nothing
Just _ -> do
send_message message send_message message
pure (Just a) pure (Just a)
Connect a -> do Connect a -> do