From d4d183034f566345c57589acba8669b987692847 Mon Sep 17 00:00:00 2001 From: Philippe Pittoli Date: Mon, 25 Mar 2024 01:03:47 +0100 Subject: [PATCH] Automatically display a notification on error log. --- src/App/Container.purs | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/App/Container.purs b/src/App/Container.purs index 281c777..c7d9611 100644 --- a/src/App/Container.purs +++ b/src/App/Container.purs @@ -328,7 +328,12 @@ handleAction = case _ of Administration -> H.liftEffect $ Storage.setItem "current-page" "Administration" sessionstorage H.modify_ _ { current_page = page } - Log message -> H.tell _log unit $ AppLog.Log message + Log message -> do + _ <- case message of + UnableToSend err -> handleAction $ AddNotif $ BadNotification err + ErrorLog err -> handleAction $ AddNotif $ BadNotification err + _ -> pure unit + H.tell _log unit $ AppLog.Log message ToggleAuthenticated maybe_token -> case maybe_token of Nothing -> H.tell _nav unit $ NavigationInterface.ToggleLogged false @@ -367,7 +372,7 @@ handleAction = case _ of handleAction AuthenticateToDNSManager NavigationInterfaceEvent ev -> case ev of - NavigationInterface.Log message -> H.tell _log unit (AppLog.Log message) + NavigationInterface.Log message -> handleAction $ Log message NavigationInterface.Routing page -> handleAction $ Routing page NavigationInterface.Disconnection -> handleAction $ Disconnection @@ -390,15 +395,15 @@ handleAction = case _ of H.tell _ws_auth unit (WS.ToSend message) AI.AuthenticateToAuthd v -> handleAction $ AuthenticateToAuthd (Right v) - AI.Log message -> H.tell _log unit (AppLog.Log message) + AI.Log message -> handleAction $ Log message RegistrationInterfaceEvent ev -> case ev of RI.MessageToSend message -> H.tell _ws_auth unit (WS.ToSend message) - RI.Log message -> H.tell _log unit (AppLog.Log message) + RI.Log message -> handleAction $ Log message MailValidationInterfaceEvent ev -> case ev of MVI.MessageToSend message -> H.tell _ws_auth unit (WS.ToSend message) - MVI.Log message -> H.tell _log unit (AppLog.Log message) + MVI.Log message -> handleAction $ Log message SetupInterfaceEvent ev -> case ev of SetupInterface.DeleteUserAccount -> do @@ -421,11 +426,11 @@ handleAction = case _ of } H.tell _ws_auth unit (WS.ToSend message) - SetupInterface.Log message -> H.tell _log unit (AppLog.Log message) + SetupInterface.Log message -> handleAction $ Log message AdministrationEvent ev -> case ev of AdminInterface.MessageToSend message -> H.tell _ws_auth unit (WS.ToSend message) - AdminInterface.Log message -> H.tell _log unit (AppLog.Log message) + AdminInterface.Log message -> handleAction $ Log message AdminInterface.StoreState s -> H.modify_ _ { store_AuthenticationDaemonAdmin_state = Just s } AdminInterface.AskState -> do state <- H.get @@ -444,11 +449,11 @@ handleAction = case _ of ZoneInterfaceEvent ev -> case ev of ZoneInterface.MessageToSend message -> H.tell _ws_dns unit (WS.ToSend message) - ZoneInterface.Log message -> H.tell _log unit (AppLog.Log message) + ZoneInterface.Log message -> handleAction $ Log message DomainListComponentEvent ev -> case ev of DomainListInterface.MessageToSend message -> H.tell _ws_dns unit (WS.ToSend message) - DomainListInterface.Log message -> H.tell _log unit (AppLog.Log message) + DomainListInterface.Log message -> handleAction $ Log message DomainListInterface.StoreState s -> H.modify_ _ { store_DomainListInterface_state = Just s } DomainListInterface.ChangePageZoneInterface domain -> do handleAction $ Routing $ Zone domain @@ -476,7 +481,7 @@ handleAction = case _ of WS.WSJustClosed -> do H.tell _ai unit AI.ConnectionIsDown H.tell _admini unit AdminInterface.ConnectionIsDown - WS.Log message -> H.tell _log unit (AppLog.Log message) + WS.Log message -> handleAction $ Log message WS.KeepAlive -> handleAction $ KeepAlive $ Left unit DecodeAuthMessage message -> do @@ -645,7 +650,7 @@ handleAction = case _ of handleAction AuthenticateToDNSManager H.tell _dli unit DomainListInterface.ConnectionIsUp WS.WSJustClosed -> H.tell _dli unit DomainListInterface.ConnectionIsDown - WS.Log message -> H.tell _log unit (AppLog.Log message) + WS.Log message -> handleAction $ Log message WS.KeepAlive -> handleAction $ KeepAlive $ Right unit -- | `DecodeDNSMessage`: decode a received `dnsmanagerd` message, then transfer it to `DispatchDNSMessage`.