mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-05-10 23:47:11 +00:00
ios: deliver notifications instantly when server has no more messages and better concurrency (#5872)
* core: return error and message absence when getting notifications * ios: do not wait for notification messages when server says "no" * do not postpone some notification events, comments * refactor * simplexmq (mapM) * simplexmq (release lock) * ios: inline, more aggressive GHC RTC settings for garbage collection * simplexmq * corrections Co-authored-by: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> * refactor ntf delivery * ios: 6.3.4 (build 274) * simplexmq (fix updating last ts) * improve notification for multiple messages * simplexmq --------- Co-authored-by: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com>
This commit is contained in:
@@ -708,7 +708,7 @@ data ChatResponse
|
||||
| CRNtfTokenStatus {status :: NtfTknStatus}
|
||||
| CRNtfToken {token :: DeviceToken, status :: NtfTknStatus, ntfMode :: NotificationsMode, ntfServer :: NtfServer}
|
||||
| CRNtfConns {ntfConns :: [NtfConn]}
|
||||
| CRConnNtfMessages {receivedMsgs :: NonEmpty (Maybe NtfMsgInfo)}
|
||||
| CRConnNtfMessages {receivedMsgs :: NonEmpty RcvNtfMsgInfo}
|
||||
| CRContactConnectionDeleted {user :: User, connection :: PendingContactConnection}
|
||||
| CRRemoteHostList {remoteHosts :: [RemoteHostInfo]}
|
||||
| CRCurrentRemoteHost {remoteHost_ :: Maybe RemoteHostInfo}
|
||||
@@ -1139,13 +1139,20 @@ data NtfConn = NtfConn
|
||||
}
|
||||
deriving (Show)
|
||||
|
||||
-- brokerTs is the same msgTs, it is used in ConnMsgReq / APIGetConnNtfMessages
|
||||
-- msgTs is broker message timestamp, it is used in ConnMsgReq / APIGetConnNtfMessages
|
||||
-- to set it as last connection message in case queue is empty
|
||||
data NtfMsgInfo = NtfMsgInfo {msgId :: Text, msgTs :: UTCTime}
|
||||
deriving (Show)
|
||||
|
||||
receivedMsgInfo :: SMPMsgMeta -> NtfMsgInfo
|
||||
receivedMsgInfo SMPMsgMeta {msgId, msgTs} = ntfMsgInfo_ msgId msgTs
|
||||
data RcvNtfMsgInfo
|
||||
= RNMInfo {ntfMsgInfo :: Maybe NtfMsgInfo}
|
||||
| RNMError {ntfMsgError :: AgentErrorType}
|
||||
deriving (Show)
|
||||
|
||||
receivedMsgInfo :: Either AgentErrorType (Maybe SMPMsgMeta) -> RcvNtfMsgInfo
|
||||
receivedMsgInfo = \case
|
||||
Right msgMeta_ -> RNMInfo $ (\SMPMsgMeta {msgId, msgTs} -> ntfMsgInfo_ msgId msgTs) <$> msgMeta_
|
||||
Left e -> RNMError e
|
||||
|
||||
expectedMsgInfo :: NMsgMeta -> NtfMsgInfo
|
||||
expectedMsgInfo NMsgMeta {msgId, msgTs} = ntfMsgInfo_ msgId msgTs
|
||||
@@ -1642,6 +1649,8 @@ $(JQ.deriveJSON defaultJSON ''UserProfileUpdateSummary)
|
||||
|
||||
$(JQ.deriveJSON defaultJSON ''NtfMsgInfo)
|
||||
|
||||
$(JQ.deriveJSON (sumTypeJSON $ dropPrefix "RNM") ''RcvNtfMsgInfo)
|
||||
|
||||
$(JQ.deriveJSON defaultJSON ''NtfConn)
|
||||
|
||||
$(JQ.deriveJSON defaultJSON ''NtfMsgAckInfo)
|
||||
|
||||
Reference in New Issue
Block a user