update entity connection status to report it correctly (#257)

This commit is contained in:
Evgeny Poberezkin 2022-02-02 17:01:12 +00:00 committed by GitHub
parent 38424af48e
commit dafdf66ada
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -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

View File

@ -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,