Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
epoberezkin committed Apr 7, 2024
1 parent 297db05 commit 6d3a513
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/Simplex/Messaging/Agent.hs
Original file line number Diff line number Diff line change
Expand Up @@ -416,13 +416,12 @@ getNetworkConfig = readTVarIO . useNetworkConfig

setUserNetworkInfo :: AgentClient -> UserNetworkInfo -> IO ()
setUserNetworkInfo c@AgentClient {userNetworkState = ns} UserNetworkInfo {networkType = nt} = withAgentEnv' c $ do
RetryInterval {initialInterval = offlineDelay} <- asks $ userNetworkInterval . config
d <- asks $ initialInterval . userNetworkInterval . config
ts <- liftIO getCurrentTime
atomically $
readTVar ns >>= \case
UNSOnline | nt == UNNone -> writeTVar ns UNSOffline {offlineDelay, offlineFrom = ts}
UNSOffline {} | nt /= UNNone -> writeTVar ns UNSOnline
_ -> pure ()
atomically . modifyTVar' ns $ \case
UNSOnline | nt == UNNone -> UNSOffline {offlineDelay = d, offlineFrom = ts}
UNSOffline {} | nt /= UNNone -> UNSOnline
s -> s

reconnectAllServers :: AgentClient -> IO ()
reconnectAllServers c = do
Expand Down

0 comments on commit 6d3a513

Please sign in to comment.