From e6f6e478d67e49c7e8c5f8432c6fcd587c8e4024 Mon Sep 17 00:00:00 2001 From: TheDaemoness Date: Thu, 15 Aug 2024 09:31:26 -0700 Subject: [PATCH] Reload server settings on /reload --- src/Client/Commands.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Client/Commands.hs b/src/Client/Commands.hs index 06ec7fcf..5786cf1e 100644 --- a/src/Client/Commands.hs +++ b/src/Client/Commands.hs @@ -37,13 +37,14 @@ import Client.State import Client.State.Extensions (clientCommandExtension, clientStartExtensions) import Client.State.Focus import Client.State.Help (hsQuery, helpQueryToText) -import Client.State.Network (csNick, isChannelIdentifier, sendMsg) +import Client.State.Network (csNick, csSettings, isChannelIdentifier, sendMsg) import Client.State.Url import Control.Applicative (liftA2, (<|>)) import Control.Exception (displayException, try) import Control.Lens import Control.Monad (guard, foldM) import Data.Foldable (foldl', toList) +import Data.HashMap.Strict qualified as HashMap import Data.Maybe (fromMaybe) import Data.Text (Text) import Data.Text qualified as Text @@ -415,10 +416,15 @@ cmdReload st mbPath = Left e -> commandFailureMsg (describeProblem e) st Right (path',cfg) -> do st1 <- clientStartExtensions + $ over clientConnections (HashMap.mapWithKey updateNetConfig) $ set clientConfig cfg $ set clientConfigPath path' st commandSuccess st1 - + where + updateNetConfig name cs = + case HashMap.lookup name $ _configServers cfg of + Nothing -> cs + Just netcfg -> set csSettings netcfg cs where describeProblem err = Text.pack $