Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reload server settings on /reload #127

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/Client/Commands.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 $
Expand Down
Loading