WIP: make job chain of disappearing messages job, expiration update job, and config sync job

pull/941/head
ryanzhao 2 years ago
parent d81a8743ac
commit aace269359

@ -2,6 +2,7 @@
import UIKit import UIKit
import SessionUIKit import SessionUIKit
import CoreMedia
public protocol VideoPreviewDelegate: AnyObject { public protocol VideoPreviewDelegate: AnyObject {
func cameraDidConfirmTurningOn() func cameraDidConfirmTurningOn()

@ -538,16 +538,9 @@ public extension Interaction {
interactionInfo: [InteractionReadInfo], interactionInfo: [InteractionReadInfo],
lastReadTimestampMs: Int64 lastReadTimestampMs: Int64
) throws { ) throws {
// Update the last read timestamp if needed
try SessionUtil.syncThreadLastReadIfNeeded(
db,
threadId: threadId,
threadVariant: threadVariant,
lastReadTimestampMs: lastReadTimestampMs
)
// Add the 'DisappearingMessagesJob' if needed - this will update any expiring // Add the 'DisappearingMessagesJob' if needed - this will update any expiring
// messages `expiresStartedAtMs` values // messages `expiresStartedAtMs` values in local database, and create seperate
// jobs updating message expiration
JobRunner.upsert( JobRunner.upsert(
db, db,
job: DisappearingMessagesJob.updateNextRunIfNeeded( job: DisappearingMessagesJob.updateNextRunIfNeeded(
@ -558,6 +551,14 @@ public extension Interaction {
) )
) )
// Update the last read timestamp if needed
try SessionUtil.syncThreadLastReadIfNeeded(
db,
threadId: threadId,
threadVariant: threadVariant,
lastReadTimestampMs: lastReadTimestampMs
)
// Clear out any notifications for the interactions we mark as read // Clear out any notifications for the interactions we mark as read
Environment.shared?.notificationsManager.wrappedValue?.cancelNotifications( Environment.shared?.notificationsManager.wrappedValue?.cancelNotifications(
identifiers: interactionInfo identifiers: interactionInfo

@ -194,7 +194,7 @@ public extension DisappearingMessagesJob {
interactionExpirationInfosByExpiresInSeconds.forEach { expiresInSeconds, expirationInfos in interactionExpirationInfosByExpiresInSeconds.forEach { expiresInSeconds, expirationInfos in
let expirationTimestampMs: Int64 = Int64(startedAtMs + expiresInSeconds * 1000) let expirationTimestampMs: Int64 = Int64(startedAtMs + expiresInSeconds * 1000)
JobRunner.add( JobRunner.upsert(
db, db,
job: Job( job: Job(
variant: .expirationUpdate, variant: .expirationUpdate,

Loading…
Cancel
Save