diff --git a/src/Simplex/Chat.hs b/src/Simplex/Chat.hs index 8b8e867d05..58b4e28074 100644 --- a/src/Simplex/Chat.hs +++ b/src/Simplex/Chat.hs @@ -357,19 +357,19 @@ processChatCommand user@User {userId, profile} = \case QuitChat -> liftIO exitSuccess ShowVersion -> pure CRVersionInfo where - procCmd :: m ChatResponse -> m ChatResponse - procCmd action = do - -- below code would make command responses asynchronous where they can be slow - -- in View.hs `r'` should be defined as `id` in this case - ChatController {chatLock = l, smpAgent = a, outputQ = q, idsDrg = gVar} <- ask - corrId <- liftIO $ SMP.CorrId <$> randomBytes gVar 8 - void . forkIO $ - withAgentLock a . withLock l $ - (atomically . writeTBQueue q) . (Just corrId,) =<< (action `catchError` (pure . CRChatError)) - pure $ CRCmdAccepted corrId - -- use function below to make commands "synchronous" + -- below code would make command responses asynchronous where they can be slow + -- in View.hs `r'` should be defined as `id` in this case -- procCmd :: m ChatResponse -> m ChatResponse - -- procCmd action = action + -- procCmd action = do + -- ChatController {chatLock = l, smpAgent = a, outputQ = q, idsDrg = gVar} <- ask + -- corrId <- liftIO $ SMP.CorrId <$> randomBytes gVar 8 + -- void . forkIO $ + -- withAgentLock a . withLock l $ + -- (atomically . writeTBQueue q) . (Just corrId,) =<< (action `catchError` (pure . CRChatError)) + -- pure $ CRCmdAccepted corrId + -- use function below to make commands "synchronous" + procCmd :: m ChatResponse -> m ChatResponse + procCmd = id connect :: ConnectionRequestUri c -> ChatMsgEvent -> m () connect cReq msg = do connId <- withAgent $ \a -> joinConnection a cReq $ directMessage msg diff --git a/src/Simplex/Chat/View.hs b/src/Simplex/Chat/View.hs index 527ce3bacf..69dc24282c 100644 --- a/src/Simplex/Chat/View.hs +++ b/src/Simplex/Chat/View.hs @@ -118,8 +118,8 @@ responseToView cmd = \case api = (highlight cmd :) r = (plain cmd :) -- this function should be `r` for "synchronous", `id` for "asynchronous" command responses - -- r' = r - r' = id + -- r' = id + r' = r viewChatItem :: ChatInfo c -> ChatItem c d -> [StyledString] viewChatItem chat (ChatItem cd meta content) = case (chat, cd) of