From e81923cdefb7d73ee76125928dad16bea3164af3 Mon Sep 17 00:00:00 2001 From: Ryan ZHAO <> Date: Mon, 8 Jan 2024 14:48:36 +1100 Subject: [PATCH] fix an issue when updating expiry unchanged messages won't start disappear --- .../Message Cells/VisibleMessageCell.swift | 1 - .../Jobs/Types/ExpirationUpdateJob.swift | 27 +++++++++++-------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Session/Conversations/Message Cells/VisibleMessageCell.swift b/Session/Conversations/Message Cells/VisibleMessageCell.swift index f80bd0d93..70d973e18 100644 --- a/Session/Conversations/Message Cells/VisibleMessageCell.swift +++ b/Session/Conversations/Message Cells/VisibleMessageCell.swift @@ -254,7 +254,6 @@ final class VisibleMessageCell: MessageCell, TappableLabelDelegate { timerView.set(.width, to: VisibleMessageCell.messageStatusImageViewSize) timerView.set(.height, to: VisibleMessageCell.messageStatusImageViewSize) messageStatusLabel.center(.vertical, in: messageStatusContainerView) -// messageStatusLabel.pin(.leading, to: .leading, of: messageStatusContainerView) messageStatusLabelPaddingView.pin(.leading, to: .leading, of: messageStatusContainerView) messageStatusLabelPaddingView.pin(.trailing, to: .trailing, of: messageStatusContainerView) } diff --git a/SessionMessagingKit/Jobs/Types/ExpirationUpdateJob.swift b/SessionMessagingKit/Jobs/Types/ExpirationUpdateJob.swift index af1647537..2e4977e8a 100644 --- a/SessionMessagingKit/Jobs/Types/ExpirationUpdateJob.swift +++ b/SessionMessagingKit/Jobs/Types/ExpirationUpdateJob.swift @@ -63,26 +63,31 @@ public enum ExpirationUpdateJob: JobExecutor { guard !unchangedMessages.isEmpty else { return } dependencies.storage.writeAsync(using: dependencies) { db in - try unchangedMessages.forEach { updatedExpiry, hashes in - try hashes.forEach { hash in + unchangedMessages.forEach { updatedExpiry, hashes in + hashes.forEach { hash in guard - let expiresInSeconds: TimeInterval = try? Interaction + let interaction: Interaction = try? Interaction .filter(Interaction.Columns.serverHash == hash) - .select(Interaction.Columns.expiresInSeconds) - .asRequest(of: TimeInterval.self) - .fetchOne(db) + .fetchOne(db), + let expiresInSeconds: TimeInterval = interaction.expiresInSeconds else { return } let expiresStartedAtMs: TimeInterval = TimeInterval(updatedExpiry - UInt64(expiresInSeconds * 1000)) - _ = try Interaction - .filter(Interaction.Columns.serverHash == hash) - .updateAll( + dependencies.jobRunner.upsert( + db, + job: DisappearingMessagesJob.updateNextRunIfNeeded( db, - Interaction.Columns.expiresStartedAtMs.set(to: expiresStartedAtMs) - ) + interaction: interaction, + startedAtMs: expiresStartedAtMs + ), + canStartJob: true, + using: dependencies + ) } } + + } } )