make control message disappears as the settings

pull/941/head
ryanzhao 2 years ago
parent 1a4343e6df
commit 49c019a9d4

@ -102,11 +102,11 @@ public struct Interaction: Codable, Identifiable, Equatable, FetchableRecord, Mu
switch self {
case .standardIncoming: return true
case .infoCall: return true
case .infoDisappearingMessagesUpdate, .infoScreenshotNotification, .infoMediaSavedNotification: return true
case .standardOutgoing, .standardIncomingDeleted: return false
case .infoClosedGroupCreated, .infoClosedGroupUpdated, .infoClosedGroupCurrentUserLeft,
.infoDisappearingMessagesUpdate, .infoScreenshotNotification, .infoMediaSavedNotification,
.infoMessageRequestAccepted:
return false
}
@ -559,11 +559,23 @@ public extension Interaction {
.asRequest(of: Int64.self)
.fetchAll(db)
let disappearingInteractionQuery = Interaction
.filter(Interaction.Columns.threadId == threadId)
.filter(Interaction.Columns.timestampMs <= interactionInfo.timestampMs)
.filter(Interaction.Columns.wasRead == true)
.filter(Interaction.Columns.expiresInSeconds != nil)
.filter(Interaction.Columns.expiresStartedAtMs == nil)
let disappearingInteractionIds: [Int64] = try disappearingInteractionQuery
.select(.id)
.asRequest(of: Int64.self)
.fetchAll(db)
// If there are no other interactions to mark as read then just schedule the jobs
// for this interaction (need to ensure the disapeparing messages run for sync'ed
// outgoing messages which will always have 'wasRead' as false)
guard !interactionIdsToMarkAsRead.isEmpty else {
scheduleJobs(interactionIds: [interactionId])
scheduleJobs(interactionIds: [interactionId].appending(contentsOf: disappearingInteractionIds))
return
}
@ -571,7 +583,7 @@ public extension Interaction {
try interactionQuery.updateAll(db, Columns.wasRead.set(to: true))
// Retrieve the interaction ids we want to update
scheduleJobs(interactionIds: interactionIdsToMarkAsRead)
scheduleJobs(interactionIds: interactionIdsToMarkAsRead.appending(contentsOf: disappearingInteractionIds))
}
/// This method flags sent messages as read for the specified recipients

Loading…
Cancel
Save