fix an issue when updating expiry unchanged messages won't start disappear

pull/731/head
Ryan ZHAO 2 years ago
parent 87309ccba1
commit e81923cdef

@ -254,7 +254,6 @@ final class VisibleMessageCell: MessageCell, TappableLabelDelegate {
timerView.set(.width, to: VisibleMessageCell.messageStatusImageViewSize) timerView.set(.width, to: VisibleMessageCell.messageStatusImageViewSize)
timerView.set(.height, to: VisibleMessageCell.messageStatusImageViewSize) timerView.set(.height, to: VisibleMessageCell.messageStatusImageViewSize)
messageStatusLabel.center(.vertical, in: messageStatusContainerView) messageStatusLabel.center(.vertical, in: messageStatusContainerView)
// messageStatusLabel.pin(.leading, to: .leading, of: messageStatusContainerView)
messageStatusLabelPaddingView.pin(.leading, to: .leading, of: messageStatusContainerView) messageStatusLabelPaddingView.pin(.leading, to: .leading, of: messageStatusContainerView)
messageStatusLabelPaddingView.pin(.trailing, to: .trailing, of: messageStatusContainerView) messageStatusLabelPaddingView.pin(.trailing, to: .trailing, of: messageStatusContainerView)
} }

@ -63,26 +63,31 @@ public enum ExpirationUpdateJob: JobExecutor {
guard !unchangedMessages.isEmpty else { return } guard !unchangedMessages.isEmpty else { return }
dependencies.storage.writeAsync(using: dependencies) { db in dependencies.storage.writeAsync(using: dependencies) { db in
try unchangedMessages.forEach { updatedExpiry, hashes in unchangedMessages.forEach { updatedExpiry, hashes in
try hashes.forEach { hash in hashes.forEach { hash in
guard guard
let expiresInSeconds: TimeInterval = try? Interaction let interaction: Interaction = try? Interaction
.filter(Interaction.Columns.serverHash == hash) .filter(Interaction.Columns.serverHash == hash)
.select(Interaction.Columns.expiresInSeconds) .fetchOne(db),
.asRequest(of: TimeInterval.self) let expiresInSeconds: TimeInterval = interaction.expiresInSeconds
.fetchOne(db)
else { return } else { return }
let expiresStartedAtMs: TimeInterval = TimeInterval(updatedExpiry - UInt64(expiresInSeconds * 1000)) let expiresStartedAtMs: TimeInterval = TimeInterval(updatedExpiry - UInt64(expiresInSeconds * 1000))
_ = try Interaction dependencies.jobRunner.upsert(
.filter(Interaction.Columns.serverHash == hash) db,
.updateAll( job: DisappearingMessagesJob.updateNextRunIfNeeded(
db, db,
Interaction.Columns.expiresStartedAtMs.set(to: expiresStartedAtMs) interaction: interaction,
) startedAtMs: expiresStartedAtMs
),
canStartJob: true,
using: dependencies
)
} }
} }
} }
} }
) )

Loading…
Cancel
Save