diff --git a/src/Simplex/Chat.hs b/src/Simplex/Chat.hs index 046a5abfb..95ab009c3 100644 --- a/src/Simplex/Chat.hs +++ b/src/Simplex/Chat.hs @@ -1678,7 +1678,7 @@ processAgentMessage (Just user@User {userId, profile}) agentConnId agentMessage -- practically, this should not happen call_ <- atomically (TM.lookupInsert contactId call' calls) forM_ call_ $ \call -> updateCallItemStatus userId ct call WCSDisconnected Nothing - toView $ CRCallInvitation ct callType sharedKey + toView . CRCallInvitation ct callType sharedKey $ chatItemTs' ci toView . CRNewChatItem $ AChatItem SCTDirect SMDRcv (DirectChat ct) ci where saveCallItem status = saveRcvChatItem user (CDDirectRcv ct) msg msgMeta (CIRcvCall status 0) Nothing diff --git a/src/Simplex/Chat/Controller.hs b/src/Simplex/Chat/Controller.hs index 331bb61e4..b3bf5c53e 100644 --- a/src/Simplex/Chat/Controller.hs +++ b/src/Simplex/Chat/Controller.hs @@ -21,6 +21,7 @@ import Data.Int (Int64) import Data.Map.Strict (Map) import Data.Text (Text) import Data.Time (ZonedTime) +import Data.Time.Clock (UTCTime) import Data.Version (showVersion) import Data.Word (Word16) import GHC.Generics (Generic) @@ -259,7 +260,7 @@ data ChatResponse | CRPendingSubSummary {pendingSubStatus :: [PendingSubStatus]} | CRSndFileSubError {sndFileTransfer :: SndFileTransfer, chatError :: ChatError} | CRRcvFileSubError {rcvFileTransfer :: RcvFileTransfer, chatError :: ChatError} - | CRCallInvitation {contact :: Contact, callType :: CallType, sharedKey :: Maybe C.Key} + | CRCallInvitation {contact :: Contact, callType :: CallType, sharedKey :: Maybe C.Key, callTs :: UTCTime} | CRCallOffer {contact :: Contact, callType :: CallType, offer :: WebRTCSession, sharedKey :: Maybe C.Key, askConfirmation :: Bool} | CRCallAnswer {contact :: Contact, answer :: WebRTCSession} | CRCallExtraInfo {contact :: Contact, extraInfo :: WebRTCExtraInfo} diff --git a/src/Simplex/Chat/Messages.hs b/src/Simplex/Chat/Messages.hs index 9d181dadb..258873c39 100644 --- a/src/Simplex/Chat/Messages.hs +++ b/src/Simplex/Chat/Messages.hs @@ -152,6 +152,12 @@ instance ToJSON (CChatItem c) where chatItemId' :: ChatItem c d -> ChatItemId chatItemId' ChatItem {meta = CIMeta {itemId}} = itemId +chatItemTs :: CChatItem c -> UTCTime +chatItemTs (CChatItem _ ci) = chatItemTs' ci + +chatItemTs' :: ChatItem c d -> UTCTime +chatItemTs' ChatItem {meta = CIMeta {itemTs}} = itemTs + data ChatDirection (c :: ChatType) (d :: MsgDirection) where CDDirectSnd :: Contact -> ChatDirection 'CTDirect 'MDSnd CDDirectRcv :: Contact -> ChatDirection 'CTDirect 'MDRcv diff --git a/src/Simplex/Chat/Store.hs b/src/Simplex/Chat/Store.hs index 49851dbc8..f1bd801c7 100644 --- a/src/Simplex/Chat/Store.hs +++ b/src/Simplex/Chat/Store.hs @@ -2640,9 +2640,6 @@ getChatPreviews st user withPCC = ts (AChat _ Chat {chatInfo, chatItems = ci : _}) = max (chatItemTs ci) (chatInfoUpdatedAt chatInfo) ts (AChat _ Chat {chatInfo}) = chatInfoUpdatedAt chatInfo -chatItemTs :: CChatItem d -> UTCTime -chatItemTs (CChatItem _ ChatItem {meta = CIMeta {itemTs}}) = itemTs - getDirectChatPreviews_ :: DB.Connection -> User -> IO [AChat] getDirectChatPreviews_ db User {userId} = do tz <- getCurrentTimeZone