diff --git a/src/Simplex/Chat.hs b/src/Simplex/Chat.hs index be7c9e50e..9f2a71762 100644 --- a/src/Simplex/Chat.hs +++ b/src/Simplex/Chat.hs @@ -505,7 +505,7 @@ processAgentMessage user@User {userId, profile} agentConnId agentMessage = Just connStatus -> do let conn = (entityConnection acEntity) {connStatus} withStore $ \st -> updateConnectionStatus st conn connStatus - pure acEntity {entityConnection = conn} + pure $ updateEntityConnStatus acEntity connStatus Nothing -> pure acEntity isMember :: MemberId -> GroupInfo -> [GroupMember] -> Bool diff --git a/src/Simplex/Chat/Protocol.hs b/src/Simplex/Chat/Protocol.hs index a6ac03be0..3b49f3ad7 100644 --- a/src/Simplex/Chat/Protocol.hs +++ b/src/Simplex/Chat/Protocol.hs @@ -38,6 +38,16 @@ data ConnectionEntity | UserContactConnection {entityConnection :: Connection, userContact :: UserContact} deriving (Eq, Show) +updateEntityConnStatus :: ConnectionEntity -> ConnStatus -> ConnectionEntity +updateEntityConnStatus connEntity connStatus = case connEntity of + RcvDirectMsgConnection c ct_ -> RcvDirectMsgConnection (st c) ((\ct -> (ct :: Contact) {activeConn = st c}) <$> ct_) + RcvGroupMsgConnection c gInfo m@GroupMember {activeConn = c'} -> RcvGroupMsgConnection (st c) gInfo m {activeConn = st <$> c'} + SndFileConnection c ft -> SndFileConnection (st c) ft + RcvFileConnection c ft -> RcvFileConnection (st c) ft + UserContactConnection c uc -> UserContactConnection (st c) uc + where + st c = c {connStatus} + -- chat message is sent as JSON with these properties data AppMessage = AppMessage { event :: Text,