diff --git a/src/Simplex/Chat.hs b/src/Simplex/Chat.hs index 702c729ee..2a0102fec 100644 --- a/src/Simplex/Chat.hs +++ b/src/Simplex/Chat.hs @@ -1532,6 +1532,13 @@ processAgentMessage (Just User {userId}) _ "" agentMessage = case agentMessage o cs <- withStore' $ \db -> getConnectionsContacts db userId conns toView $ event srv cs showToast ("server " <> str) (safeDecodeUtf8 $ strEncode host) +processAgentMessage (Just user) _ agentConnId END = + withStore (\db -> getConnectionEntity db user $ AgentConnId agentConnId) >>= \case + RcvDirectMsgConnection _ (Just ct@Contact {localDisplayName = c}) -> do + toView $ CRContactAnotherClient ct + showToast (c <> "> ") "connected to another client" + unsetActive $ ActiveC c + entity -> toView $ CRSubscriptionEnd entity processAgentMessage (Just user@User {userId, profile}) corrId agentConnId agentMessage = (withStore (\db -> getConnectionEntity db user $ AgentConnId agentConnId) >>= updateConnStatus) >>= \case RcvDirectMsgConnection conn contact_ -> @@ -1688,11 +1695,6 @@ processAgentMessage (Just user@User {userId, profile}) corrId agentConnId agentM -- [async agent commands] continuation on receiving OK withCompletedCommand conn agentMsg $ \CommandData {cmdFunction, cmdId} -> when (cmdFunction == CFAckMessage) $ ackMsgDeliveryEvent conn cmdId - END -> do - toView $ CRContactAnotherClient ct - showToast (c <> "> ") "connected to another client" - unsetActive $ ActiveC c - -- TODO print errors MERR msgId err -> do chatItemId_ <- withStore' $ \db -> getChatItemIdByAgentMsgId db connId msgId forM_ chatItemId_ $ \chatItemId -> do diff --git a/src/Simplex/Chat/Controller.hs b/src/Simplex/Chat/Controller.hs index 8cc9d5879..92bc809ad 100644 --- a/src/Simplex/Chat/Controller.hs +++ b/src/Simplex/Chat/Controller.hs @@ -314,6 +314,7 @@ data ChatResponse | CRContactConnecting {contact :: Contact} | CRContactConnected {contact :: Contact, userCustomProfile :: Maybe Profile} | CRContactAnotherClient {contact :: Contact} + | CRSubscriptionEnd {connectionEntity :: ConnectionEntity} | CRContactsDisconnected {server :: SMPServer, contactRefs :: [ContactRef]} | CRContactsSubscribed {server :: SMPServer, contactRefs :: [ContactRef]} | CRContactSubError {contact :: Contact, chatError :: ChatError} diff --git a/src/Simplex/Chat/View.hs b/src/Simplex/Chat/View.hs index 35657d5db..0b9546703 100644 --- a/src/Simplex/Chat/View.hs +++ b/src/Simplex/Chat/View.hs @@ -134,6 +134,7 @@ responseToView testView = \case CRContactConnecting _ -> [] CRContactConnected ct userCustomProfile -> viewContactConnected ct userCustomProfile testView CRContactAnotherClient c -> [ttyContact' c <> ": contact is connected to another client"] + CRSubscriptionEnd acEntity -> [sShow (connId (entityConnection acEntity :: Connection)) <> ": END"] CRContactsDisconnected srv cs -> [plain $ "server disconnected " <> showSMPServer srv <> " (" <> contactList cs <> ")"] CRContactsSubscribed srv cs -> [plain $ "server connected " <> showSMPServer srv <> " (" <> contactList cs <> ")"] CRContactSubError c e -> [ttyContact' c <> ": contact error " <> sShow e] @@ -714,9 +715,9 @@ viewContactUpdated | n == n' && fullName == fullName' = [] | n == n' = ["contact " <> ttyContact n <> fullNameUpdate] | otherwise = - [ "contact " <> ttyContact n <> " changed to " <> ttyFullName n' fullName', - "use " <> ttyToContact n' <> highlight' "" <> " to send messages" - ] + [ "contact " <> ttyContact n <> " changed to " <> ttyFullName n' fullName', + "use " <> ttyToContact n' <> highlight' "" <> " to send messages" + ] where fullNameUpdate = if T.null fullName' || fullName' == n' then " removed full name" else " updated full name: " <> plain fullName'